“Nodemon.ps1 cannot be loaded because running scripts is disabled on this system” is a common error related to the unsafe Windows policy. The below explanations can help you know more about the cause of error and solutions.
How does the error “nodemon.ps1 cannot be loaded because running scripts is disabled on this system” happen?
This error happens due to the many following reasons:
First, it might be because running scripts is disabled on this system, as the execution policy has banned running the given script in Windows. To check this, run Powershell as administrator and run:
Second, it’s safe if you allow running remotely signed scripts on the computer. This means you can run unsigned local scripts, i.e. scripts you wrote…. Otherwise, scripts run from nodemon (remote source) must have been signed by trusted authorities. If you’re using Windows, open Settings, then choose “Update & Security”. At the “For developers” menu, scroll down to find this check box in the “PowerShell” subheading:
How to solve the error?
Solution 1: Change the current execution policy
To solve “nodemon.ps1 cannot be loaded because running scripts is disabled on this system” error, you will have to open Powershell as administrator and run this command:
Or you can use this command to change the current execution policy to RemoteSigned (the default execution policy for Windows server computers) instead of Unrestricted, this will change the policy to the CurrentUser if possible:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Now you can check again to see execution policy changes with this command
You should get 1 of 2 following outputs:
Solution 2: Change execution policy to allow local Powershell scripts to run without signing
If you’re using Windows 10 or 11, open Settings and choose Update & Security:
Click “For Developers” in the left sidebar and at the PowerShell subheading. Tick option:
Solution 3: Delete the nodemon.ps1 file
Go to this location in you computer:
Then delete the file named nodemon.ps1 and restart the terminal. Now run the code again to check if you had succeeded:
If you caught the same error, you should try cleaning npm cache and then rerun the above code:
npm cache clean --force
We have learned how to deal with the error “nodemon.ps1 cannot be loaded because running scripts is disabled on this system” in NodeJS. You can quickly solve this problem by checking the execution policy carefully and finding out the reasons causing this problem in this tutorial.
Maybe you are interested:
- ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
- “geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic”
- Error: vector memory exhausted (limit reached?)
Name of the university: HCMUT