Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The term 'ng' is not recognized as the name of a cmdlet

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 
like image 381
Wauna Avatar asked Jul 06 '17 21:07

Wauna


People also ask

Why Ng is not working in VS code?

ps1 cannot be loaded because running scripts is disabled on this system vscode. The reason is that, in build command line integrations like visual studio code, you need to set the command line policies by your self. By setting the above configurations, the visual studio code will do that for you.

What to do if Ng is not working?

To solve the error "ng is not recognized as an internal or external command, operable program or batch file", install the angular cli globally by running npm install -g @angular/cli@latest and make sure your PATH environment variable is set up correctly.

How do you fix the term npm is not recognized as the name of a cmdlet function script file or operable program?

Just add: ;C:\Program Files\nodejs\ To the end of your Path variable on the "User variable" section of the Environment Variables on the System Properties. After that, reopen your command prompt and type npm. This should work.


Video Answer


2 Answers

The first path in the path variable needs to be the NPM path. Opening the Node.js command prompt I found that the ng command worked there. I dug into the shortcut and found that it references a command to ensure the first Path variable is NPM. To Fix:

  1. Right Clicked on My Computer (windows)
  2. Selected Advanced System Settings
  3. Clicked "Environment Variables"
  4. Under "Path" variable, made the FIRST value listed %AppData%\npm

Once I did that I was able to close powershell and reopen and all worked.

like image 148
3 revs, 3 users 90% Avatar answered Oct 12 '22 09:10

3 revs, 3 users 90%


First setup Node.js, then run this command to install angular globably:

npm install -g @angular/cli 

Now run ng command. This worked for me.

like image 30
Ahmadreza Farrokhnejad Avatar answered Oct 12 '22 07:10

Ahmadreza Farrokhnejad