Reputation: 899
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?
Upvotes: 16
Views: 33395
Reputation: 1
To fix this error you have to open your Windows Powershell as administrator.
Then write
Command: set-executionpolicy remotesigned
and after that select
"A"
to Yes to all.
Hit enter and then try to run your application in VS Code's Powershell with ng serve
command.
Upvotes: 0
Reputation: 101
I had the same error on Windows.
What I did is to set Command Prompt as the default shell instead of PowerShell (PowerShell is the default) in the terminal window where you select a terminal instance.
Upvotes: 10
Reputation: 21
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
Upvotes: 0
Reputation: 187
my case working fine this command please open power shell
set-executionpolicy remotesigned -Scope CurrentUse
Upvotes: 1
Reputation: 812
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 start
Get-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.
Upvotes: 0
Reputation: 2011
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
Upvotes: 3
Reputation: 41
The effective solution is
It worked successfully.
Upvotes: 4
Reputation: 9
Not sure with your question but try using Angular-CLI commands runner inside VS Code extension in your VS Code. Works very smooth for me.
Upvotes: 0
Reputation: 211
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.
Upvotes: 21
Reputation: 345
Try doing npm install
inside your project directory and then try for ng --version
.
Upvotes: 0