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 install the Angular using
npm install -g @angular/cli
Anytime I tried to run ng I would get
the term 'ng' is not recognized as the name of a cmdlet
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.
Installing angular cli globally solved my problem.
If your project name contain '-'. Remove it and try. This can cause problem in running 'ng'.
You can also make sure you run the Command Prompt - or whatever terminal you use - As Administrator. I am using Visual Studio Code and the
ng serve
command gives me that exact error when not running VS Code as admin.First setup Node.js, then go to your project folder with the command prompt such as D:\project and then run this command:
Now run ng command. This work for me.
In the "Environment Variables"
In the "System variables" section
In the "Path" variable and before
"C:\Program Files (x86)\nodejs\"
add =>"%AppData%\npm"