Fixing npm.ps1 Cannot Be Loaded Because Running Scripts is Disabled on Windows
Let's Solve the Execution Policy Error and Get Back to Coding

You're all set, installed VS Code and Node Package Manager on a fresh Windows setup, ready to code.
You type npm install
and… boom, this error blindsides you:
npm : File C:\Program Files\nodejs\npm.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.
At line:1 char:1
+ npm install
+ ~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
No need to panic at all, in fact this is a super common PowerShell security enforcement policy setting that prevents script execution by default.
It's called a Windows Powershell Execution Policy and here's how to fix it to work with npm:
To set the execution policy to RemoteSigned, and with CurrentUser Scope, open up Windows Powershell as Administrator, and enter the following command and press Enter:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
You will be prompted as follows:
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust.
Changing the execution policy might expose you to the security risks
described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170.
Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
To continue, and save the change, which is saved in the configuration file and remains effective until you change it again, press Y
and Enter
to confirm.
This allows trusted local scripts to run, and remote scripts only if they're signed...
a developer-friendly setting indeed!
The change is effective immediately and you don't even need to restart PowerShell.
Want to dig into Windows Powershell Execution Policies?
Recommended Articles

Are Your Competitors Building AI Empires While You Sleep?
AI in Business, a practical guide. Learn how to use intelligence in business to augment, automate and stay ahead. Start now so you don't get left behind later.

Bob's Basic Guide to Markdown
Markdown is a lightweight markup language used to format text. I'm using right now to write this basic examples of Markdown article. Let's get started with the basic examples of Markdown to showcase some of Markdown's features.