npm : File C:\Program Files\nodejs\npm.ps1 cannot be loaded because running scripts is disabled on this system
Hi Techies,
I recently encounter this issue while running npm commands on Visual Studio. Below is my understanding & its solution for new techies.
Why - When you install Node.js, the npm command is added to your system's PATH as a PowerShell script (npm.ps1). If the execution policy in PowerShell is set to Restricted or AllSigned, PowerShell prevents scripts like npm.ps1 from running, resulting in this error.
Solution -
1 - Find Powershell
2 - Run as a Administrator
3 - Execute "Set-ExecutionPolicy RemoteSigned"
4 - you will get options - Choose option [A] Yes to all
5 - Come to terminal in VS code (restart it) and try executing npm command