When running commands installed by npm (i.e. yarn, ng, etc.), I receive the following error:
File C:\Users\<username>\AppData\Roaming\npm\<application> cannot be loaded because running scripts is disabled on this system.
where <application> is one of the commands installed by npm (i.e. yarn, ng, etc.)
How can this issue be resolved?
ps1 cannot be loaded because running scripts is disabled on this system" occurs when the execution policy does not allow running the specific script on Windows. Use the Set-ExecutionPolicy -ExecutionPolicy RemoteSigned command to solve the error.
appdata/Roaming was made for data to roam with the user. Concrete example of this: If user A logs into machine A and npm installs, then the cache will be stored in appdata/roaming on machine A.
Use the Set-ExecutionPolicy -ExecutionPolicy RemoteSigned command to solve the error. Open your PowerShell as an administrator and set its execution policy with the Set-ExecutionPolicy command. Copied! The Set-ExecutionPolicy command sets the PowerShell execution policy for the Windows computer.
I just try this command in VS terminal(PowerShell) and my problem has been solved
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser
note : don't change CurrentUser to your username
edit : you can follow this link for changing the visual studio code terminal to cmd.exe instead of PowerShell and it will work without any security issues. https://blog.jongallant.com/2017/02/vs-code-integrated-terminal-powershell-default-change-to-cmd/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With