Solvedangular cli Can't install angular-cli globally

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Mac OSX El Capitan

  1. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:

latest

  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.

npm install -g angular-cli
or
sudo npm install -g angular-cli
or
npm install -g angular-cli@latest

  1. The log given by the failure. Normally this include a stack trace and some
    more information.
canker:Angular CanKer$ sudo npm install -g angular-cli
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated lodash-node@2.4.1: This package has been discontinued in favor of lodash@^4.0.0.
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
/usr/local/bin/ng -> /usr/local/lib/node_modules/angular-cli/bin/ng

> fsevents@1.0.14 install /usr/local/lib/node_modules/angular-cli/node_modules/fsevents
> node-pre-gyp install --fallback-to-build

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
sh: node-pre-gyp: command not found
npm WARN install:fsevents@1.0.14 fsevents@1.0.14 install: `node-pre-gyp install --fallback-to-build`
npm WARN install:fsevents@1.0.14 spawn ENOENT

> execSync@1.0.2 install /usr/local/lib/node_modules/angular-cli/node_modules/execSync
> node install.js

shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
sh: node: command not found
/usr/local/lib
`-- (empty)

npm WARN string-replace-loader@1.0.3 requires a peer of webpack@1.x.x || 2.x.x but none was installed.
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "angular-cli"
npm ERR! node v6.6.0
npm ERR! npm  v3.10.3
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! execSync@1.0.2 install: `node install.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the execSync@1.0.2 install script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the execSync package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs execSync
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls execSync
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/CanKer/Documents/Projekte/Angular/npm-debug.log
npm ERR! code 1 
  1. Mention any other details that might be useful.

I'd installed not globally by error before and if I write npm view angular-cli version I see 1.0.0-beta.14 but I can't use the commands like ng new...


Thanks! We'll be in touch soon.

57 Answers

✔️Accepted Answer

Try to clean cache npm cache clean, uninstall angular-cli npm uninstall -g angular-cli & install again npm install -g angular-cli

Other Answers:

npm install -g -f angular-cli @karthikkavin

Hello I just installed with -f or --force flag and it worked.
I should close this and thank you all for your time. :)

@neilhem
The following worked for me
npm cache clean
npm uninstall -g angular-cli
npm install -g -f angular-cli
ng --help

Thats it.

Has anyone used yarn package manager. Its fast, easy, understandable (meaningful). You can :

  1. Install yarn
    npm install yarn -g
  2. use yarn to install angular-cli
    yarn global add angular-cli.

Done thats its it worked for me.

More Issues: