Unable to execute Angular CLI commands in Visual Studio Code terminal
Solution 1
I got the following error message while executing ng serve from VSCode:
File C:\Users\\AppData\Roaming\npm\ng.ps1 cannot be loaded because running scripts is disabled on this system...
Solution:
I was able to solve the issue by running the following command in PowerShell:
set-executionpolicy remotesigned
Make sure to run PowerShell with admin privileges. More on this solution can be read here.
Solution 2
I had the same error in Windows. what I did is I set Command Prompt as the default shell Instead of PowerShell (PowerShell is default) in the terminal window where you select a terminal instance
Solution 3
The effective solution is
- opening the microsoft studio code by run as administrator
- set-executionpolicy remotesigned
- ng serve
It worked successfully.
user2636874
Updated on June 07, 2022Comments
-
user2636874 almost 2 years
I'm unable to execute
Angular CLI
commands in Visual Studio Code terminal. When I typeng --version
in the terminal, it is opening the ng file instead of executing the command.Any idea of how to resolve the above issue?
-
user2636874 about 5 yearsI have tried creating the project in command prompt using ng new command like ng new test-proj. after that from visual studio code I opened the above folder and next in terminal, I ran the command npm install, it executed well. after that I ran the command ng --version, then instead of executing the ng command, it is opening the ng file.
-
Damika over 2 yearsPlease do mention what is the reason to do such a change
-
nicolascolman about 2 yearsThis is the easiest and most accurate answer