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 : UnauthorizedAccessNo 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 CurrentUserYou 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"): YTo 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

How to Backup Your Supabase Database for Free
Learn how to backup your Supabase database using pg_dump and PostgreSQL tools, even on the free tier. Includes troubleshooting common connection issues and step-by-step instructions.

React Hooks: A Complete Guide to Modern State Management
Learn everything you need to know about React Hooks, from the basics of useState and useEffect to creating powerful custom hooks. This comprehensive guide includes real-world examples and best practices for modern React development.