I'm unable to execute Angular CLI commands from the Visual Studio Code terminal.
When I type ng --version in the terminal, it is opening the ng file instead of executing the command.
Any idea of how to resolve the above issue?
I'm unable to execute Angular CLI commands from the Visual Studio Code terminal.
When I type ng --version in the terminal, it is opening the ng file instead of executing the command.
Any idea of how to resolve the above issue?
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.
When you open a new terminal in VS Code, in the top right corner you are given a couple option icons:

Click on the dropdown icon and you get a couple options to choose from:
There is also a "Configure Terminal Settings" which allows you to change the default terminal window
Type npm start instead of ng serve.
Try doing npm install inside your project directory and then try for ng --version.
I too faced to this problem. And
npm start instead of ng serve I think the reason for this is, angular's dev server is webpack. And on default webpack works on development mode with npm startGet-ExecutionPolicy on power shell of vs-code -> I got RestrictedGet-ExecutionPolicy -List to get all of the execution policies with their scorps. And I got the follwing result :/MachinePolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined
Then I rechecked the error which was displayed at the beginning, in vs-code power shell
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied. To change the execution policy
execution policy for the current user, run "Set-ExecutionPolicy -Scope CurrentUser".
In there too it's mentioned the err is about the current-user
So I execute
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
And it worked for me. It's pleasure if this would work to you too thanks.
ng serve comand opens an editor instead of loading local URL Issue
Solution: This is the terminal editor on the 'ng' alias. Uninstall it with:
Command: sudo apt purge ng-common ng-latin
Then install Angular CLI (assuming you have npm installed) with Command: sudo npm install -g @angular/cli
After that You can use all ng commands