Search code examples
javascriptnode.jsangular-clinpm-installnode-sass

Error with install angular-cli with node-sass


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
> node-sass@4.7.2 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
> uglifyjs-webpack-plugin@0.4.6 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: fsevents@1.1.3 (node_modules/@angular/cli/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.7.2 (node_modules/@angular/cli/node_modules/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.7.2 install: `node scripts/install.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! uglifyjs-webpack-plugin@0.4.6 postinstall: `node lib/post_install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the uglifyjs-webpack-plugin@0.4.6 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?


Solution

  • 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