angular-cli: 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
├── angular-cli@0.0.33
├── broccoli-plugin@1.2.0
└── broccoli-source@1.1.0
Running on a Macos.
Am i missing something?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 6
- Comments: 73 (5 by maintainers)
Removing NODE and using NVM instead fixed a lot of issues.
nvm install stable
npm install -g angular-cli
seems to fixed when i add a alias in my bash_profile
but that should not be the way to do, right…?
npm install npm@latest -g
should solve the npm-cli problem “NO SUDO”@mcferren It is solved by adding the address of the module installation at ** PATH** computer in my case
or
npm link @angular/cli
fixed this for me.I have tried all sorts of things, but this did it.
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli
Cheers.
Hi,
I was also coming across this issue on the MacOS Siera (10.12.2), and I managed to fix the issue following the next steps (I provided the whole steps to install the angular-cli, including the way to add the correct link into ~/.bash_profile
Prerequisites the following versions need to be installed (https://www.npmjs.com/package/angular-cli#prerequisites )
Because I installed the node and npm using the brew package manager I would go with it for updating the node and npm to the required versions
$ brew update && brew upgrade node && npm install -g npm
Check the versions with
Installation
$ npm install -g angular-cli
Try to see if the ng is successfully installed on your machine with:
$ ng --version
In same cases (this was also my cases) the packages are successfully installed but the ng command is not seen in command prompt (See the filed issue https://github.com/angular/angular-cli/issues/503 ). If this is the case follow the following instructions:See where are the angular-cli installations
$ npm link angular-cli
On my machine the command returns /Users/antonelpazargic/.npm-packages/lib/node_modules/angular-cli/node_modules/angular-cli -> /Users/antonelpazargic/.npm-packages/lib/node_modules/angular-cliEdit the ~/bash_profile in order to include a link to one of the link command return paths + /bin/ng For me:
alias ng="/Users/xxxxxxxx/.npm-packages/lib/node_modules/angular-cli/bin/ng"
$ . ~/bash_profile
Test the installation with
$ ng --version
Apparently this is still an issue. Installed angular-cli today, read all the suggestions here. Nothing works. Had to manually add a symlink.
npm link @angular/cli was enough
With the latest @angular/cli package (prev called angilar-cli and renamed @angular/cli)
I think nvm is a good workaround, but you just have to add this line to your bash-profile:
Same problem here running Windows 10 x64 / NodeJS 6.9.1 / npm 3.10.9: After installation of Angular CLI via npm, the ‘ng’ command cannot be found.
Uninstalled npm with npm uninstall -g npm Uninstalled NodeJS via control panel / programs and features Downloaded and ran ‘old’ NodeJS installer release 6.5.0 from https://nodejs.org/download/release/v6.5.0/ (node-v6.5.0-x64.msi). After NodeJS 6.5.0 installation completed, open powershell and npm install -g angular-cli Grab quick coffee After installation completed, ng worked OK.
HTH
Windows users, add
%APPDATA%/npm
to thePath
variable and relaunch your terminal.For me, it is a problem of adding a Path in to bash_profile for Mac (like global variable in the system): Step 1: Find where your angular-cli is installed. You can find the path in terminal after you run
npm install -g @angular-cli
Step 2:Get the path, for example, “/usr/local/lib/node_modules/lib/node_modules/@angular/cli/bin”, I know it is a bit wired…
Step 3: Open your .bash_profile:
vi ~/.bash_profile
Step 4: Add the path in step 2 in bash_profile like this:
export PATH=/usr/local/lib/node_modules/lib/node_modules/@angular/cli/bin:$PATH
Step 5: Save and quit your vi editor by ‘wq’. In the end, you need to
source ~/.bash_profile
to make your changes work.After that, you may need to close and reopen your terminal window to let it work. It works for me, hope it also works for you.
same problem for me: ng: command not found
I am on apple osX 10.9.5
$ node --version v6.5.0 $ npm --version 3.10.3
This finally worked for me:
alias ng="/Users/MY_USER_NAME/.npm-global/lib/node_modules/@angular/cli/bin/ng"
I know it’s frustrating to hear, but there isn’t much that we can do here on this repo. If after global install the
ng
isn’t available, it means that either the install failed or that yournpm
is broken/misconfigured/having problems. Those kind of issues should be filed against https://github.com/npm/npmI’m using nvm on an ubuntu machine, i solved by using alias too, like this
alias ng="/root/.nvm/versions/node/v6.3.1/lib/node_modules/angular-cli/bin/ng"
On macOS 10.13 (High Sierra) the easiest way to get angular-cli is via brew (Homebrew): http://brewformulas.org/AngularCli
Didn’t give me any troubles at all.
for some reason my path was no longer compatible with everything I was exporting in my bash profile,
so type “echo $PATH” and check your path, if npm/bin isnt there add it again through the bash_profile.
Being in the Home directory, simply running:
alias ng="npm/lib/node_modules/angular-cli/bin/ng"
In terminal did fix the issue
If your IDE is like mine (Cloud 9) the node version default may be something like 4.5.1. Do an upgrade to at least version 6.5.0 as shown above. In addition your IDE may shut your work space session down after being idle. That may reset everything back to the default node version. You can use this command to set the current session to the node version you need.
$ nvm use 6.5.0
This worked for me and ‘ng’ commands were back and life was good again.
Why is this marked as closed? This issue happened for me today on an Ubuntu server using Node (not NVM)
There was no ‘lib’ folder in
/home/[user]/.npm/lib
for me to symlinkI ended up removing node and installing nvm, but that can’t be an acceptable solution, right?
@mcferren see https://github.com/npm/npm/issues/13828 tienes buscar en tu ordenador la ruta en donde npm instala los paquetes globales y esa ruta añadirla a la variable “PATH” de tu sistema operativo para que este recocnosca los comandos instalados
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’m learning Angular on a fresh Windows 7 install and went through the instructions and also got the ng not found error in git bash (mingw32): https://angular.io/guide/quickstart Step 2
SYSTEM@Dave-E6540 MINGW32 ~ $ ng new my-app bash: ng: command not found
I followed instructions elsewhere to run some commands to determine the path I need to add but it was already added to the Windows Environment Variables for User (since I only installed it for me), and adding it to the System PATH also had no effect (see Start > right-click Computer > Properties > Advanced system settings > Advanced tab > Environment Variables button).
SYSTEM@Dave-E6540 MINGW32 ~ $ npm list -g --depth=0 C:\Users\Dave\AppData\Roaming\npm `-- @angular/cli@1.4.3
SYSTEM@Dave-E6540 MINGW32 ~ $ npm config get prefix C:\Users\Dave\AppData\Roaming\npm
The only thing that worked was adding the path in git bash as: export PATH=$PATH:/c/Users/Dave/AppData/Roaming/npm
Not sure if I’ll have to re-add it every session or what the permanent solution is, but the Node install should be able to do this already. Wasn’t expecting to hit a roadblock so early, maybe the developer needs to double-check this and reconfigure the install to set the path correctly or if they’re not able to do that at least mention the fix for it during the install or documentation.
Also posible solution is to reexport (or to verify) path to your …/usr/bin: