How to Fix "npm : File C:\Program Files\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system." Error

How to Fix "npm : File C:\Program Files\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system." Error

Today, I encountered a common issue while running an NPM command in PowerShell:

Error:

File C:\Program Files\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system.        

This happens due to PowerShell’s execution policy settings. Here's a step-by-step guide to resolve it:

?? Solution:

Open PowerShell as Administrator:

  • Search for "PowerShell" in the Start menu.
  • Right-click on "Windows PowerShell" and select "Run as administrator."

Change the Execution Policy:

  • Allow script execution by running:

Set-ExecutionPolicy RemoteSigned        

  • Confirm the change by typing Y and pressing Enter.

Verify the Execution Policy:

  • Check the current policy with:

Get-ExecutionPolicy        

  • It should display RemoteSigned.

Run Your NPM Command Again:

  • Now, execute your npm command:

npm create vite@latest        

?? Important: Always be cautious when changing the execution policy. Only run scripts from trusted sources. To revert to the default policy:

Set-ExecutionPolicy Restricted        

Hashtags: #PowerShell #NodeJS #NPM #WebDevelopment #TechTips #Coding #JavaScript #DevOps #DeveloperCommunity

Reference: https://vitejs.dev

Happy coding! ???

Dev Sahu

A dreamer

1 天前

Thanks it worked for me as well , but will this step make my device prone to malicious attacks?

回复
Alfi Artya Diwanda

Freelance Sports Illustrator

3 天前

I have this issue but is it become risk to my system even though I didn't use it for code? Thanks for the tips ??

回复
Alex Cassady

Software Engineer

1 周

Thanks so much! I had no idea about Powershell Execution Policy's.

回复

Thank you!

回复
Md Ahmodullah

Frontend Developer | React & MERN Stack Enthusiast | Creating Impactful, User-Centric Web Experiences | Always Learning & Innovating ??

2 周

Helpful

回复

要查看或添加评论,请登录

Najmul Hasan的更多文章

社区洞察

其他会员也浏览了