Ng command not found angular-cli when creating a new project in windows

I successfully install node.js and angularjs2 with this command. node version

node version v6.9.1 npm install -g angular-cli 

and the installation path is that

 C:\Users\Arobil\AppData\Roaming\npm\node_modules\angular-cli\bin 

which include

 system->advanced system setting->Environment variable->path 

but the problem is that when I create a new project using angular it

D:> the new application 'ng' is not recognized as an internal or external command, operating program or batch file.

Am I missing something?

+10
source share
6 answers

You just need to add the path to the environment variable. To do this, follow these steps. go to the properties of my computer β†’ advanced system settings β†’ environment variable β†’ add a new variable and assign a path to your NPM.

For example, my NPM path: -

path: D: \ Users \ goldy.b \ AppData \ Roaming \ npm

+4
source share

I am using a Mac and it worked for me.

alias ng = "/ Users / Batman/.npm-packages/lib/ node_modules / @ angular / cli / bin / ng"

+3
source share
  1. Remove all npm uninstall -g angular-cli
  npm uninstall -g @angular/cli npm cache clean 
  1. Reinstall
 npm install -g @angular/cli 

Now look into your global NPM folder, it should be something like "/Users//.npm-global/bin/". Here you should see your corner CLI files. To check if everything works, try typing:

  ng -v 

If this does not work, try manually adding an alias that displays ng to your ng folder, for example like this:

  alias ng="/Users/<username>/.npm-global/bin/ng" 

I also had problems when I did not have 'sudo' permissions. To get around this, you can change your global path. To do this, you can do something like this in your ~ / .bash_profile:

 export PATH="$HOME/.npm-packages/bin:$PATH" 

Taken from here

+1
source share

I had the same problem. Just change the name of your project and it will work.

0
source share

After entering the entry in the path variable for the folder C: / Users / {userName} / Appdata / Roaming / npm, run the following command: prefix npm config get get and check if the output matches the above, that is C: / Users / {username } / Appdata / Roaming / NMP.

If the path does not match, make sure you run the npm config prefix set APPDATA \ Roaming \ npm command. Now, after installing angular / cli using -g, all relevant packages will be downloaded to this folder, and you will be able to run ng commands from any directory on your computer.

0
source share

You need to link your corner cli to npm using

npm link @angular/cli

It works like a charm

0
source share

All Articles