I tried to use the global "nodemon" function in the powershell of Visual Studio Code. I am using Node.js. When I try to use the "nodemon" function, I get an error stating that "FileName cannot be loaded because running scripts is disabled on this system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170." Does anyone know how to enable running scripts and resolve the issue?
I tried entering the file path after "nodemon" but I got the same error.
2
Answers
You can use Set-ExecutionPolicy to do this:
-Scope CurrentUser
sets the execution policy for the current user. Different values are available and listed here-ExecutionPolicy Unrestricted
sets the execution policy for the specified scope. All list of the possible values are listed hereHowever, please be aware that this does have security implications, so only do this if you trust the scripts you want to run.
To revert this change to block all scripts again, you can use
For more information about execution policies: learn.microsoft.com
Running scripts is sort of a security feature in powershell. Here are a list of the different types of running script execution policies:
If you aren’t going to be working with any potentially harmful or unknown script in powershell (nodemon isn’t one), you can set the policy to Unrestricted.
You will need to open powershell as administrator, then paste in the following:
Set-ExecutionPolicy Unrestricted
You can change the Execution policy to whichever you desire but it may not fit the requirements of running nodemon.
Set-ExecutionPolicy [Execution Policy Here]