This article will show you how to fix the error “create-react-app.ps1 cannot be loaded because running scripts is disabled on this system” in some ways, such as using the command set-execution policy remotesigned, restarting your node server or checking your npm version.
The reason of the error “Create-react-app.ps1 cannot be loaded because running scripts is disabled on this system”
When we run the command to create a new project using npm, for example, below, then this error appears.
npx create-react-app your-project-name
create-react-app.ps1: File C:\Users\yuu\Documents\GitHub cannot be loaded because running scripts is disabled on this system
This error occurs due to system settings and also because your npm version is no longer supported or it has stopped working. So how can we prevent the error from appearing again? Let’s see the solutions in the next part of the article.
How to fix this error?
Using the command set-execution policy remotesigned
- Restricted: PowerShell commands are locked by default, meaning that users can only enter commands and not carry them out.
- All Signed: The code will be executed, but only for the components that have been explicitly specified if either you or the administrator select the All Signed level.
- Remote Signed: security policy at this level permits the operation of any PowerShell code generated within the local system. When the entire attribute is assigned, remote-generated code cannot run.
- Unrestricted: do not impose any restrictions on the system.
Because the command is not being run, maybe because the system settings are preventing it, you should change it like this:
- Select Start on the desktop and look up Windows Powershell
- Right-click the icon and select Run as Administrator
- Run the command set-execution policy remotesigned
Then you run the react project creation command again and see the result.
Restarting your node server
Or your node server needs to be fixed. You can turn it off and on again and then try again.
- First, open the task manager by using Ctrl+Alt+Delete
- Then you will find the node server and select the end task
- Finally, you reopen the node server and then run the command to create the project again
By doing this, you can fix this error because running scripts are disabled on this system, or you can check your current npm version to see if it is the latest version. Good luck with the above solutions.
To summarize, the article introduced you two ways to fix the error “create-react-app.ps1 cannot be loaded because running scripts is disabled on this system”, but in my opinion, using the command set-execution policy remotesigned is the most thorough way to fix this error.
Maybe you are interested:
- You are running `create-react-app` 4.0.3, which is behind the latest release (5.0.0)
- `value` prop on `input` should not be null in React
Name of the university: PTIT