How to fix error- nodemon.ps1 cannot be loaded because running scripts is disabled on this system, (without security risk)?

TradeCoder picture TradeCoder · Aug 15, 2020 · Viewed 24.6k times · Source

Error on terminal: nodemon.ps1 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.

I have a solution to fix the issue by this way

  1. Open Windows PowerShell with Run as Administrator
  2. Run this command: Set-ExecutionPolicy Unrestricted

That solves the issue, but this way the system shows Security Risk Warning. My question: Is there any other way to solve this without security risk? Target is to use nodemon.

Answer

derekbaker783 picture derekbaker783 · Aug 15, 2020

I'd recommend using RemoteSigned as opposed to Unrestricted, and limiting the policy to the current user if possible.

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

RemoteSigned: "The default execution policy for Windows server computers."



Other than that, I wouldn't worry about it too much, as it's not intended to be a security mechanism. See this quote from the docs:

"The execution policy isn't a security system that restricts user actions. For example, users can easily bypass a policy by typing the script contents at the command line when they cannot run a script. Instead, the execution policy helps users to set basic rules and prevents them from violating them unintentionally."