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

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 symlink

I ended up removing node and installing nvm, but that can't be an acceptable solution, right?

AlexReff avatar Sep 22 '16 16:09 AlexReff

@AlexReff -- is your PATH as noted in the referenced NPM 13828 issue correct?

JanStureNielsen avatar Sep 22 '16 20:09 JanStureNielsen

That topic is specific to Windows. This was not on a Windows platform.

AlexReff avatar Sep 22 '16 22:09 AlexReff

Still occuring with node v5.6.0 npm v3.6.0. Using alias fix.

m477r33d avatar Sep 26 '16 00:09 m477r33d

I changed the alias, now I get this error, now how do I undo the alias?

-bash: /root/.nvm/versions/node/v6.3.1/lib/node_modules/angular-cli/bin/ng: No such file or directory

and Mac Users do not try to change the alias, it wont solve the problem

maddymaster avatar Sep 29 '16 09:09 maddymaster

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 your npm is broken/misconfigured/having problems. Those kind of issues should be filed against https://github.com/npm/npm

filipesilva avatar Oct 02 '16 20:10 filipesilva

Same problem here using Windows 10 and actual installer.

wumpz avatar Oct 07 '16 06:10 wumpz

Same problem with it. npm command is working fine, so the problem is with angular-cli as ng command is ot working

aniruddhadas9 avatar Oct 18 '16 22:10 aniruddhadas9

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

MattKane avatar Nov 14 '16 20:11 MattKane

Thank you. This solution works for me

Sluchik avatar Nov 22 '16 12:11 Sluchik

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 )

  • Node 4 or higher
  • NPM 3 or higher

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

$ node --version
$ npm --version

Installation

  • Install the angular-cli

$ 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-cli

  • Edit 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

jtonic avatar Dec 29 '16 20:12 jtonic

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.

bofcarbon1 avatar Feb 01 '17 17:02 bofcarbon1

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:

open ~/.bash_profile
alias ng="/Users/xxxxx/.npm-packages/lib/node_modules/@angular/cli/bin/ng"

fr4ngus avatar Feb 14 '17 12:02 fr4ngus

open ~/.zshrc alias ng="~/lib/node_modules/@angular/cli/bin/ng"

ipavlyk avatar Feb 16 '17 09:02 ipavlyk

Update.....

I started a new MEAN stack node.js app on Cloud 9 (Ubuntu) and when using node 6.5.0 got a message that I should convert to 6.10. Used 6.10.1 and that would not recognize 'ng' commands. Changing this 'bash_profile' may or may not be possible developing from an IDE tool where you don't own the file. So I went back to 6.5.0 and it worked fine. I don't understand why the new 6.10.1 version would cause the 'ng' script file to not be found. I'm sticking with 6.5.0 for now warning or not at least it works.

bofcarbon1 avatar Mar 27 '17 23:03 bofcarbon1

Also posible solution is to reexport (or to verify) path to your .../usr/bin:

export PATH=$HOME/bin:$PATH

ipavlyk avatar Mar 28 '17 07:03 ipavlyk

Are you talking about setting this PATH inside of my application? Not om my machine? I use a cloud service to create my code which sits on Ubuntu. Where would I set the PATH? In which project file?

B

bofcarbon1 avatar Mar 28 '17 09:03 bofcarbon1

I was talking about bin folder which contains refs on cli(s).

ipavlyk avatar Mar 28 '17 11:03 ipavlyk

Being in the Home directory, simply running:

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

In terminal did fix the issue

iyunusov avatar May 02 '17 14:05 iyunusov

I was running node v4.5.0. Updating to v8.1.1 fixed the issue for me.

JasonMonroe-EdgeTech avatar Jun 14 '17 17:06 JasonMonroe-EdgeTech