angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng: command not found

Open reinos opened this issue 10 years ago • 73 comments

After installing angular-cli with the help of this https://github.com/angular/angular-cli/issues/389#issuecomment-213420501 i installed Angular-cli successfully.

After that i tried a ng command ng --help what gave me the following message. -bash: ng: command not found

Running npm list -g --depth=0 shows me that angular-cli is installed.

ReinosMac:~ reinos$ npm list -g --depth=0
/Users/reinos/.npm/lib
├── [email protected]
├── [email protected]
└── [email protected]

Running on a Macos.

Am i missing something?

reinos avatar Apr 22 '16 14:04 reinos

seems to fixed when i add a alias in my bash_profile

alias ng="/Users/reinos/.npm/lib/node_modules/angular-cli/bin/ng"

but that should not be the way to do, right...?

After trying it does not work, I tried another way and it add the line alias ng="~/npm-global/bin/ng"

tuandnguyen97 avatar Oct 23 '18 02:10 tuandnguyen97

npm link @angular/cli was enough

lutonda avatar Nov 08 '18 18:11 lutonda

ng doesn't seem to be recognized if installed locally but not globally. However, if you run ng through npm it works. Why is that the case? In most cases, it doesn't hurt to install globally, however, when I set up a build pipeline, I have to install angular/cli globally first and then add an npm install step. That ends up installing angular/cli twice since most projects also have a dependency on angular/cli. The best solution around that is to avoid ng commands and run everything through npm scripts. However, we shouldn't have to be limited to invoking ng that way.

adamtki avatar Dec 14 '18 03:12 adamtki

Wow that was a wasted afternoon. my main problem was that once I closed the terminal and opened a new one - it did not recognise the ng command any more. the following code, suggested above, solved my problem:

 Removing NODE and using NVM instead fixed a lot of issues.
removing Node from your system
install NVM from here https://github.com/creationix/nvm
Install Node via NVM: nvm install stable
run npm install -g @angular/cli

as suggetsted above worked for me.

shlomoko avatar Jan 02 '19 10:01 shlomoko

I started facing this issue when I upgraded node to v10.15.0 using nvm. I tried to uninstall/re-install angular/cli, also tried many above solutions but it did not work. While installing angular-cli it was always making link to v8.9.4 (I would see v8.9.4 getting added inside nvm automatically). Finally I removed all node versions from nvm, installed node v8.9.4 and then installed angular-cli. This time it worked properly.

manishamsathe avatar Jan 10 '19 14:01 manishamsathe

fixed this issue by using the aliasing others where talking about. Though it was coming up in the global npm installs, it seems to somehow have ended up in a different directory from the others. I added the following command (on windows) and it worked for me.

alias ng="c:/Users/andre/.global-modules/node_modules/@angular/cli/bin/ng"

CLantigua2 avatar Mar 06 '19 04:03 CLantigua2

I solved my problem doing this..

npm install -g @angular/cli --latest and everything working great now.

dlhenke avatar Mar 14 '19 17:03 dlhenke

I solved it this way here are the steps, https://stackoverflow.com/questions/37227794/ng-command-not-found-while-creating-new-project-using-angular-cli/55179821#55179821

divyanshu-rawat avatar Mar 15 '19 09:03 divyanshu-rawat

I had to uninstall and reinstall node.js, then it worked.

dtarvin avatar May 16 '19 18:05 dtarvin

For me @NatasaPeic solution reinstalling angular-cli worked.

markus-hsk avatar Aug 07 '19 09:08 markus-hsk

npm install -g angular-cli (seems deprecated)

I have got the solution by doing this npm install -g @angular/cli

sinha2773 avatar Aug 09 '19 07:08 sinha2773

I started experiencing this about a month ago. I had created a project and then one day it just stopped working. So I looked into my situation.

OS: Windows 10 - x64 Enterprise 10.0.1622

$ npm -g list --depth=0

    C:\Users\bryan.wood\AppData\Roaming\npm
    +-- @angular/[email protected]
   `-- [email protected]

I tried adding my npm folder to the Environment Path variable, but that actually made things worse. It broke NPM itself!

I decided to look into why that was, starting with the C:/Users folder. Turns out the IT department doesn't remove other users from the machines it distributes. I went back to the Environment Variables and started looking around. When I added my path variable it was to the User EV PATH variable. When I opened the System EV Path variable I noticed another NPM path!

Turns out a previous user of my machine had installed NodeJS/NPM global for all users. This did not come up in the installer for NodeJS when I apparently did the same thing. And it looks to have used that users global NPM path and did not install one for me.

My Solution

  1. Remove Global System NPM path
  2. Add User NPM Path

You can add the path manually or install nodejs again and make sure to select "for me only" and it should install your NPM path in the User EV PATH variable.

itanex avatar Sep 04 '19 17:09 itanex

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.