Reputation: 75
I'm new to working with either Angular or visual studio code. I installed node.js and npm which are working fine. The command for running a project ng serve
, runs perfectly on the command prompt. But, when I switch to the terminal area of the vs code and run the same command ng serve
, it throws an error as below.
ng : The term 'ng' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:1 char:1
+ ng serve
+ ~~
+ CategoryInfo : ObjectNotFound: (ng:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Then again, if I use npm run ng serve
, it works just like how it should work in vs code terminal.
Is it how it works? If not, what should I do to make it work to just use ng serve
to run the project?
Upvotes: 0
Views: 7645
Reputation: 135
Hopefully this saves someone headache in the future - I had this exact problem, because I switch terminals a lot and I also switch node versions using nvm when Im dealing with developing on different Angular versions... The reason I kept getting 'command ng not found', was because each version of node that you use has its OWN node_modules global folder, so you need to install angular globally for each node version. My folder structure was $HOME/.nvm/versions/x.x.x/lib/node_modules/@angular
Make sure you install your packages globally for EACH node version you use with nvm!
Upvotes: 0
Reputation: 54
I think you can Shift + Right click in your folder so you can open powershell and then do npm install -g @angular/cli
and then generate your project. I think it should work.
Upvotes: 1