Angular-cli: Problem : -bash: ng: command not found

Created on 18 Nov 2017  路  7Comments  路  Source: angular/angular-cli

$ node -v
v8.9.1
$ npm -v
5.5.1

OS X EI CAPITAN V10.16
ERROR:
$ ng 鈥攙ersion:
-bash: ng: command not found

Log:
$ sudo npm install --unsafe-perm -g angular-cli
Password:
npm WARN deprecated [email protected]: angular-cli has been renamed to @angular/cli. Please update your dependencies.
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
/Users/maniksrivastava/.npm-global/bin/ng -> /Users/maniksrivastava/.npm-global/lib/node_modules/angular-cli/bin/ng

[email protected] install /Users/maniksrivastava/.npm-global/lib/node_modules/angular-cli/node_modules/fsevents
node install

[fsevents] Success: "/Users/maniksrivastava/.npm-global/lib/node_modules/angular-cli/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile

[email protected] install /Users/maniksrivastava/.npm-global/lib/node_modules/angular-cli/node_modules/node-sass
node scripts/install.js

Cached binary found at /Users/maniksrivastava/.npm/node-sass/4.7.1/darwin-x64-57_binding.node

[email protected] postinstall /Users/maniksrivastava/.npm-global/lib/node_modules/angular-cli/node_modules/node-sass
node scripts/build.js

Binary found at /Users/maniksrivastava/.npm-global/lib/node_modules/angular-cli/node_modules/node-sass/vendor/darwin-x64-57/binding.node
Testing binary
Binary is fine
npm WARN @angular/[email protected] requires a peer of rxjs@^5.0.1 but none is installed. You must install peer dependencies yourself.

  • [email protected]
    added 900 packages in 62.983s
    >>>> $ ng --version
    -bash: ng: command not found
    >>>> $ npm install --unsafe-perm -g rxjs@^5.0.1
  • [email protected]
    updated 1 package in 5.559s
    >>>> $ ng --version
    -bash: ng: command not found

Most helpful comment

Hey there,you have met the dependencies for angular-cli but accessing _ng_ over terminal requires you to set the path for global packages in your path environment.

Path known

  • Assuming you have a global modules set up for npm _(by default ~/.node_modules_global)_
    $ npm prefix -g

  • Now set the path of modules/bin to our bash path environment to access over terminal

$ echo -e "export PATH=$(npm prefix -g)/bin:$PATH" >> ~/.bashrc 
$ source ~/.bashrc

How about setting a new one!

$ mkdir ~/path/module
$ npm config set prefix '~/path/module'
$ sudo chown -R $USER <directory>

Now the final touch, install angular/cli package
npm install -g @angular/cli

All 7 comments

@manikGit try npm i -g @angular/cli

$ sudo npm i -g @angular/cli
Password:
npm WARN gentlyRm not removing /Users/maniksrivastava/.npm-global/bin/ng as it wasn't installed by /Users/maniksrivastava/.npm-global/lib/node_modules/@angular/cli
/Users/maniksrivastava/.npm-global/bin/ng -> /Users/maniksrivastava/.npm-global/lib/node_modules/@angular/cli/bin/ng

  • @angular/[email protected]
    updated 4 packages in 34.974s
    $ ng --version
    -bash: ng: command not found

Hey there,you have met the dependencies for angular-cli but accessing _ng_ over terminal requires you to set the path for global packages in your path environment.

Path known

  • Assuming you have a global modules set up for npm _(by default ~/.node_modules_global)_
    $ npm prefix -g

  • Now set the path of modules/bin to our bash path environment to access over terminal

$ echo -e "export PATH=$(npm prefix -g)/bin:$PATH" >> ~/.bashrc 
$ source ~/.bashrc

How about setting a new one!

$ mkdir ~/path/module
$ npm config set prefix '~/path/module'
$ sudo chown -R $USER <directory>

Now the final touch, install angular/cli package
npm install -g @angular/cli

$ ng --version

Angular CLI: 1.5.2
Node: 8.9.1
OS: darwin x64

Thanks @guhan62 . It worked.

@guhan62 when I type source ~/.bashrc
-bash: export: Studio.app/sdk/platform-tools:/Applications/Android': not a valid identifier -bash: export:Studio.app/sdk/tools': not a valid identifier

@fayeyen, sorry just saw that you had mentioned me to solve the issue.

Seems like you have an issue with Android studio bin linking to the source. I would recommend that you could remove the SDK link in your ~/.bashrc.

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._

Was this page helpful?
0 / 5 - 0 ratings