Visual studio code cmd error: Cannot be loaded because running scripts is disabled on this system

This article will show you, via a series of examples, how to fix the Cannot Be Loaded Because Running Scripts Is Disabled On This System Visual Studio Code problem that occurs in code.

ng : File C:\Users\sam\AppData\Roaming\npm\ng.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

  • ng new ang
  • ~~
    • CategoryInfo : SecurityError: (:) [], PSSecurityException
    • FullyQualifiedErrorId : UnauthorizedAccess

The simplest way to deal with this problem from Visual Studio Code is to change from powerShell to cmd (assuming there’s no reason for using powershell in your case). To do so, follow these few steps:

First Method

File -> Preferences -> Settings and in the search bar write “automation”.

After that, by looking your operating system enter “edit in settings.json”.

Finally, add the following b/n the braces:

"terminal.integrated.shellArgs.windows": ["-ExecutionPolicy", "Bypass"]


add following in vscode > settings.json

"terminal.integrated.profiles.windows": {
  "PowerShell": {
    "source": "PowerShell",
      "icon": "terminal-powershell",
        "args": ["-ExecutionPolicy", "Bypass"]
  }
},
"terminal.integrated.defaultProfile.windows": "PowerShell"

Second Method

  1. Press the windows-button on your keyboard
  2. Type ‘PowerShell’
  3. Right-click Windows PowerShell
  4. Click Run as Administrator
  5. Run the following command and confirm with ‘Y’
  6. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

SAY THANKS, ASK QUESTIONS OR GIVE FEEDBACK

Technologies get updated, syntax changes and honestly… I make mistakes too. If something is incorrect, incomplete or doesn’t work, let me know in the comments below and help thousands of visitors.

Leave a Reply

Your email address will not be published. Required fields are marked *

Live Updates COVID-19 CASES