ng: command not found
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?
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"
npm link @angular/cli was enough
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.
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.
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.
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"
I solved my problem doing this..
npm install -g @angular/cli --latest and everything working great now.
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
I had to uninstall and reinstall node.js, then it worked.
For me @NatasaPeic solution reinstalling angular-cli worked.
npm install -g angular-cli (seems deprecated)
I have got the solution by doing this npm install -g @angular/cli
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
- Remove Global System NPM path
- 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.
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.