12

i am successfully install node.js and angularjs2 using this command. node version is

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 are include

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

but the problem is that when i create new project using angular its

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

Am i missing anything?

3

7 Answers 7

6
  1. Uninstall Everything npm uninstall -g angular-cli
 npm uninstall -g @angular/cli

 npm cache clean
  1. Re-install
npm install -g @angular/cli

Now have a look in your global NPM folder, it should be something like "/Users//.npm-global/bin/". In here you should see your angular CLI files. To test if everything works, try typing:

 ng -v

If this does not work, then try manually adding an alias that mappings ng to your ng folder, like so:

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

I've also had issues where I have not had 'sudo' permissions. To get around this you can change your global path. To do this you can do something like this within your ~/.bash_profile :

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

Taken from here

Sign up to request clarification or add additional context in comments.

2 Comments

ng -v does not seem to be a valid command. Did you mean ng --version?
this is not working and I dont have /Users/username/.npm-global directory
4

You just need to add path in Your Environment Variable. To do this, follow these steps. go to my computer properties >> advanced system settings >> environment variable >> add new variable and assign path to your NPM.

For Example my NPM path:-

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

Comments

3

I am using Mac and this worked for me.

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

Comments

1

You need to link your angular cli with npm using

npm link @angular/cli

That worked like a charm

Comments

0

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

Comments

0

After making an entry to the path variable for C:/Users/{userName}/Appdata/Roaming/npm folder, run the following command npm config get prefix and check whether the output is consistent with the above one i.e. C:/Users/{userName}/Appdata/Roaming/npm.

If the path is not same, make sure that you run the command npm config set prefix "APPDATA\Roaming\npm". Now once you install the angular/cli using -g all corresponding packages will be downloaded in this folder and you will be able to run ng commands from any directory of your machine.

Comments

0

If your OS is Windows consider that Power Shell does not support Angular CLI commands... try with command prompt (and remember to open with administrator rights!)

1 Comment

I thought powershell could run any command that cmd could

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.