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

Problem : -bash: ng: command not found

Open manikGit opened this issue 9 years ago • 7 comments

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

OS X EI CAPITAN V10.16 ERROR: $ ng —version: -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.

$ ng --version -bash: ng: command not found $ npm install --unsafe-perm -g rxjs@^5.0.1

$ ng --version -bash: ng: command not found

manikGit avatar Nov 18 '17 22:11 manikGit

@manikGit try npm i -g @angular/cli

glebmachine avatar Nov 19 '17 10:11 glebmachine

$ 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

manikGit avatar Nov 19 '17 18:11 manikGit

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

guhan62 avatar Nov 19 '17 20:11 guhan62

$ ng --version

Angular CLI: 1.5.2 Node: 8.9.1 OS: darwin x64

Thanks @guhan62 . It worked.

manikGit avatar Nov 19 '17 22:11 manikGit

@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 avatar Nov 30 '17 10:11 fayeyen

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

guhan62 avatar Feb 21 '18 18:02 guhan62

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.