Today, while working through some basic AngularJS Intro, I ran into a problem.
I opened PowerShell to get going on the project. NPM worked.
I was able to in
The problem is NOT the install of the NPM nor the path ! If you want to use the "ng" command you need to install the angular-cli. by running the following command
npm install -g @angular/cli
https://cli.angular.io/
Even though the correct answers have been given. But all of these didn't work for me because:
So for all of you who face the same issue as me here is what I did:
Instead of ng serve
I copy-pasted the complete location path of ng
like the following and it worked.
So the ng serve
command became:
C:\Users\MyUserName\AppData\Roaming\npm\ng.cmd serve
All answers are about how to fix it, but the best is to download nodeJs and let the installer add to PATH variable.
Version 12 and 13 are too new, so I had to download 11.15 https://nodejs.org/download/release/v11.15.0/
Please also make sure that the node_modules folder also exists there in the project directory. If it is not there you will get a similar issue. so please run npm install as well.
If your project name contain '-'. Remove it and try. This can cause problem in running 'ng'.
Instead of giving "ng serve" command in the Visual Studio code terminal, open angular app path in the command prompt(Run as Administrator).
Then give "ng serve" command.
Then open browser and go to the http://localhost:4200/
It works for me.