Reputation: 938
I have an Angular project and if I want to start the project with 'ng serve' it is opening the ng file from
C:\Users{user}\AppData\Roaming\npm\node_modules\@angular\cli\bin
Also, I can start the project with 'npm start'.
Upvotes: 20
Views: 17616
Reputation: 2669
In my case, ExecutionPolicy was added in my Windows machine, so I reverted by using the below command in PowerShell
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Undefined
check ExecutionPolicy through Get-ExecutionPolicy -List
Upvotes: 0
Reputation: 36
You have configured wrong environment variable path.
Path should be:
C:\Users\{UserName}\AppData\Roaming\npm
NOTE: Verify ng.cmd
file should be there in C:\Users\{UserName}\AppData\Roaming\npm
. If not please reinstall anglular cli.
Upvotes: 2
Reputation: 21
Make sure to add %USERPROFILE%\AppData\Roaming\npm
to the user variables in environment variable.
Then, close all your command window and then try again.
Upvotes: 0
Reputation: 1
In my case, i was encountered an error related to 'ng serve' it is opening the ng file. To resolve this issue, you need to upgrade to a newer version of Node.js
Upvotes: 0
Reputation: 49
Make sure you have angular cli installed globally. This worked for me:
npm install -g @angular/cli
Upvotes: 1
Reputation: 722
Here the quick way to solve the problem.You can add script command to package.json as below
"scripts": {
....
"create":"ng g c components/auth-extensions"
}
and run the command
npm run create
Once your job is done, you can delete the command from package.json.
This avoids installing global package, environment variable, path etc..
Upvotes: 1
Reputation: 71
I had a similar problem where typing ng in terminal open ng.js in vscode so my fix to it in Environment Variable remove any angular path in system variable and in user variable add this path C:\Users\Here\AppData\Roaming\npm don't forget to add your system name in the (Here)
Upvotes: 5
Reputation: 278
Remove path "C:\Users{user}\AppData\Roaming\npm\node_modules@angular\cli\bin" from Environment variable - path. It worked for me.
Upvotes: 27
Reputation: 938
The problem was that I use ng in powershell. In cmd work..
Upvotes: 10