Error with install angular-cli with node-sass

kaluginserg picture kaluginserg · Feb 9, 2018 · Viewed 8.8k times · Source

My system configuration:
debian 4.4 , nvm 0.33.8 , node v8.9.4 , npm 5.6.0 .

I want to install Angular-cli npm install -g @angular/cli. But I get an error message:

root@contracts:/home/kalugin# npm install -g @angular/cli
/root/.nvm/versions/node/v8.9.4/bin/ng -> /root/.nvm/versions/node/v8.9.4/lib/node_modules/@angular/cli/bin/ng
> [email protected] install /root/.nvm/versions/node/v8.9.4/lib/node_modules/@angular/cli/node_modules/node-sass
> node scripts/install.js
module.js:471
  throw err;
  ^
Error: Cannot find module '/root/.nvm/versions/node/v8.9.4/lib/node_modules/@angular/cli/node_modules/node-sass/scripts/install.js'
  at Function.Module._resolveFilename (module.js:469:15)
  at Function.Module._load (module.js:417:25)
  at Module.runMain (module.js:604:10)
  at run (bootstrap_node.js:394:7)
  at startup (bootstrap_node.js:149:9)
  at bootstrap_node.js:509:3
> [email protected] postinstall /root/.nvm/versions/node/v8.9.4/lib/node_modules/@angular/cli/node_modules/webpack/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js
module.js:471
  throw err;
  ^
Error: Cannot find module '/root/.nvm/versions/node/v8.9.4/lib/node_modules/@angular/cli/node_modules/webpack/node_modules/uglifyjs-webpack-plugin/lib/post_install.js'
  at Function.Module._resolveFilename (module.js:469:15)
  at Function.Module._load (module.js:417:25)
  at Module.runMain (module.js:604:10)
  at run (bootstrap_node.js:394:7)
  at startup (bootstrap_node.js:149:9)
  at bootstrap_node.js:509:3
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@angular/cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/@angular/cli/node_modules/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node scripts/install.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node lib/post_install.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!     /root/.npm/_logs/2018-02-09T17_27_50_397Z-debug.log

I tried npm cache clean, doesn't help.
I tried change node version nvm use v6.12.3, doesn't help.

debug.log pointed to the problem with node-sass package. I tried install node-sass globally - but the same error. I cannot install node-sass...

Any ideas?

Answer

nschonni picture nschonni · Feb 10, 2018

Likely the problem is because you're running as root, and NPM disables scripts automatically when you do that. Try passing the --unsafe-perm to the NPM install command