SoftTimur
SoftTimur

Reputation: 5490

Cannot install angular-cli

On my Mac, ng serve returns -bash: ng: command not found, so it seems that i need to install angular-cli. But sudo npm install -g angular-cli returns the follows.

Does anyone know what's wrong?

npm WARN deprecated [email protected]: angular-cli has been renamed to @angular/cli. Please update your dependencies.
npm WARN deprecated [email protected]: Please replace with usage of fs.existsSync
npm WARN deprecated [email protected]: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha1-wZyd+aAocC1nhhI4SmVSQExjbRU= integrity checksum failed when using sha1: wanted sha1-wZyd+aAocC1nhhI4SmVSQExjbRU= but got sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==. (15621 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM= integrity checksum failed when using sha1: wanted sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM= but got sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==. (11423 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
/usr/local/bin/ng -> /usr/local/lib/node_modules/angular-cli/bin/ng

> [email protected] install /usr/local/lib/node_modules/angular-cli/node_modules/fsevents
> node install

[fsevents] Success: "/usr/local/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 /usr/local/lib/node_modules/angular-cli/node_modules/node-sass
> node scripts/install.js

Unable to save binary /usr/local/lib/node_modules/angular-cli/node_modules/node-sass/vendor/darwin-x64-57 : { Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/vendor'
    at Object.fs.mkdirSync (fs.js:885:18)
    at sync (/usr/local/lib/node_modules/angular-cli/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/usr/local/lib/node_modules/angular-cli/node_modules/mkdirp/index.js:77:24)
    at checkAndDownloadBinary (/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/scripts/install.js:114:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/scripts/install.js:157:1)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/vendor' }

> [email protected] postinstall /usr/local/lib/node_modules/angular-cli/node_modules/node-sass
> node scripts/build.js

Building: /usr/local/bin/node /usr/local/lib/node_modules/angular-cli/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/local/bin/node',
gyp verb cli   '/usr/local/lib/node_modules/angular-cli/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:89:16
gyp verb `which` failed     at /usr/local/lib/node_modules/angular-cli/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /usr/local/lib/node_modules/angular-cli/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:89:16
gyp verb `which` failed     at /usr/local/lib/node_modules/angular-cli/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /usr/local/lib/node_modules/angular-cli/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed   stack: 'Error: not found: python2\n    at getNotFoundError (/usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:13:12)\n    at F (/usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:68:19)\n    at E (/usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:80:29)\n    at /usr/local/lib/node_modules/angular-cli/node_modules/which/which.js:89:16\n    at /usr/local/lib/node_modules/angular-cli/node_modules/isexe/index.js:42:5\n    at /usr/local/lib/node_modules/angular-cli/node_modules/isexe/mode.js:8:5\n    at FSReqWrap.oncomplete (fs.js:152:21)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `/usr/bin/python -c "import platform; print(platform.python_version());"` returned: "2.7.10\n"
gyp verb get node dir no --target version specified, falling back to host node version: 8.9.3
gyp verb command install [ '8.9.3' ]
gyp verb install input version string "8.9.3"
gyp verb install installing version: 8.9.3
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 8.9.3
gyp verb build dir attempting to create "build" dir: /usr/local/lib/node_modules/angular-cli/node_modules/node-sass/build
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/angular-cli/node_modules/node-sass/build'
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/angular-cli/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /usr/local/lib/node_modules/angular-cli/node_modules/node-sass
gyp ERR! node -v v8.9.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
Build failed with error code: 1
npm WARN @angular/[email protected] requires a peer of rxjs@^5.0.1 but none is installed. You must install peer dependencies yourself.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/softtimur/.npm/_logs/2018-05-01T05_37_47_221Z-debug.log

Edit 1:

sudo npm install -g @angular/cli returns the follows

WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha1-wZyd+aAocC1nhhI4SmVSQExjbRU= integrity checksum failed when using sha1: wanted sha1-wZyd+aAocC1nhhI4SmVSQExjbRU= but got sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==. (15621 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EINTEGRITY: sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM= integrity checksum failed when using sha1: wanted sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM= but got sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==. (11423 bytes)
WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
/usr/local/bin/ng -> /usr/local/lib/node_modules/@angular/cli/bin/ng

> [email protected] install /usr/local/lib/node_modules/@angular/cli/node_modules/fsevents
> node install

[fsevents] Success: "/usr/local/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 /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/install.js

Unable to save binary /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/vendor/darwin-x64-57 : { Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/vendor'
    at Object.fs.mkdirSync (fs.js:885:18)
    at sync (/usr/local/lib/node_modules/@angular/cli/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/usr/local/lib/node_modules/@angular/cli/node_modules/mkdirp/index.js:77:24)
    at checkAndDownloadBinary (/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/scripts/install.js:114:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/scripts/install.js:157:1)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
  errno: -13,
  code: 'EACCES',
  syscall: 'mkdir',
  path: '/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/vendor' }

> [email protected] postinstall /usr/local/lib/node_modules/@angular/cli/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js


> [email protected] postinstall /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/build.js

Building: /usr/local/bin/node /usr/local/lib/node_modules/@angular/cli/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/local/bin/node',
gyp verb cli   '/usr/local/lib/node_modules/@angular/cli/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library=' ]
gyp info using [email protected]
gyp info using [email protected] | darwin | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:89:16
gyp verb `which` failed     at /usr/local/lib/node_modules/@angular/cli/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /usr/local/lib/node_modules/@angular/cli/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:89:16
gyp verb `which` failed     at /usr/local/lib/node_modules/@angular/cli/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /usr/local/lib/node_modules/@angular/cli/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed   stack: 'Error: not found: python2\n    at getNotFoundError (/usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:13:12)\n    at F (/usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:68:19)\n    at E (/usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:80:29)\n    at /usr/local/lib/node_modules/@angular/cli/node_modules/which/which.js:89:16\n    at /usr/local/lib/node_modules/@angular/cli/node_modules/isexe/index.js:42:5\n    at /usr/local/lib/node_modules/@angular/cli/node_modules/isexe/mode.js:8:5\n    at FSReqWrap.oncomplete (fs.js:152:21)',
gyp verb `which` failed   code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `/usr/bin/python -c "import platform; print(platform.python_version());"` returned: "2.7.10\n"
gyp verb get node dir no --target version specified, falling back to host node version: 8.9.3
gyp verb command install [ '8.9.3' ]
gyp verb install input version string "8.9.3"
gyp verb install installing version: 8.9.3
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 8.9.3
gyp verb build dir attempting to create "build" dir: /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/build
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/build'
gyp ERR! System Darwin 17.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/@angular/cli/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /usr/local/lib/node_modules/@angular/cli/node_modules/node-sass
gyp ERR! node -v v8.9.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@angular/cli/node_modules/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] postinstall: `node scripts/build.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

+ @angular/[email protected]
added 995 packages in 43.182s

Upvotes: 0

Views: 2462

Answers (3)

vhbazan
vhbazan

Reputation: 1417

I think you have a permission issue in the error logs:

gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@angular/cli/node_modules/node-sass/build'

Take a look what user/group and type of access have the /usr/local/lib/ and the /usr/local/lib/node_modules/ folders.

Change it according to what you need, worst case scenario if it's local development environment you can set it to 777 just to make sure that it's a permission issue:

sudo chmod 777 /usr/local/lib/node_modules/

I hope it works.

Upvotes: 0

Lia
Lia

Reputation: 11982

based on docs Change npm's Default Directory

To minimize the chance of permissions errors, you can configure npm to use a different directory. In this example, it will be a hidden directory on your home folder.

Make a directory for global installations:

 mkdir ~/.npm-global

Configure npm to use the new directory path:

npm config set prefix '~/.npm-global'

Open or create a ~/.profile file and add this line:

 export PATH=~/.npm-global/bin:$PATH

Back on the command line, update your system variables:

source ~/.profile

Test: Download a package globally without using sudo.

npm install -g jshint

Instead of steps 2-4, you can use the corresponding ENV variable (e.g. if you don't want to modify ~/.profile):

NPM_CONFIG_PREFIX=~/.npm-global

Upvotes: 1

sagars01
sagars01

Reputation: 386

npm i -g @angular/cli

The error is written in the first line itself.

Upvotes: 1

Related Questions