Running sudo npm install node-sass throws the following error. Running the same command without sudo or with --unsafe-perm installs the package without any problems. If it's not a bug, can someone please explain why is this happening?
> [email protected] install /var/www/apollo/node_modules/node-sass
> node scripts/install.js
module.js:540
throw err;
^
Error: Cannot find module '/var/www/apollo/node_modules/node-sass/scripts/install.js'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (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 ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install 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! /home/vagrant/.npm/_logs/2018-03-01T20_10_11_333Z-debug.log
Part of /home/vagrant/.npm/_logs/2018-03-01T20_10_11_333Z-debug.log:
...
36148 info lifecycle [email protected]~install: [email protected]
36149 silly install [email protected]
36150 info lifecycle [email protected]~install: [email protected]
36151 verbose lifecycle [email protected]~install: unsafe-perm in lifecycle false
36152 verbose lifecycle [email protected]~install: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/apollo/node_modules/node-sass/node_modules/.bin:/var/www/apollo/node_modules/.bin:/home/vagrant/bin:/home/vagrant/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
36153 verbose lifecycle [email protected]~install: CWD: /var/www/apollo/node_modules/node-sass
36154 silly lifecycle [email protected]~install: Args: [ '-c', 'node scripts/install.js' ]
36155 silly lifecycle [email protected]~install: Returned: code: 1 signal: null
36156 info lifecycle [email protected]~install: Failed to exec install script
36157 verbose unlock done using /home/vagrant/.npm/_locks/staging-e5a690960657d9c9.lock for /var/www/apollo/node_modules/.staging
36158 silly saveTree apollo
36158 silly saveTree โโโฌ @fortawesome/[email protected]
36158 silly saveTree โ โโโ @fortawesome/[email protected]
36158 silly saveTree โโโฌ [email protected]
36158 silly saveTree โ โโโฌ [email protected]
36158 silly saveTree โ โ โโโฌ [email protected]
36158 silly saveTree โ โ โโโ [email protected]
...
36158 silly saveTree โ โ โโโ [email protected]
36158 silly saveTree โ โโโ [email protected]
36158 silly saveTree โโโ [email protected]
36158 silly saveTree โโโ [email protected]
36159 warn optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
36160 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
36161 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
36161 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
36161 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: linux
36161 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
36162 verbose stack Error: [email protected] install: `node scripts/install.js`
36162 verbose stack Exit status 1
36162 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
36162 verbose stack at emitTwo (events.js:126:13)
36162 verbose stack at EventEmitter.emit (events.js:214:7)
36162 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
36162 verbose stack at emitTwo (events.js:126:13)
36162 verbose stack at ChildProcess.emit (events.js:214:7)
36162 verbose stack at maybeClose (internal/child_process.js:925:16)
36162 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
36163 verbose pkgid [email protected]
36164 verbose cwd /var/www/apollo
36165 verbose Linux 4.4.0-87-generic
36166 verbose argv "/usr/bin/node" "/usr/bin/npm" "install"
36167 verbose node v8.9.4
36168 verbose npm v5.6.0
36169 error code ELIFECYCLE
36170 error errno 1
36171 error [email protected] install: `node scripts/install.js`
36171 error Exit status 1
36172 error Failed at the [email protected] install script.
36172 error This is probably not a problem with npm. There is likely additional logging output above.
36173 verbose exit [ 1, true ]
NPM version (npm -v):
5.6.0
Node version (node -v):
v8.9.4
node -p process.versions):node -p process.platform):node -p process.arch):node -p "require('node-sass').info"):npm ls node-sass):It's best to avoided running npm as sudo. If you must use sudo then you
need to pass the --unsafe-perms flag to npm install
On 2 Mar. 2018 7:26 am, "Alexandru Bau" notifications@github.com wrote:
Running sudo npm install node-sass throws the following error:
[email protected] install /var/www/apollo/node_modules/node-sass
node scripts/install.jsmodule.js:540
throw err;
^Error: Cannot find module '/var/www/apollo/node_modules/node-sass/scripts/install.js'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (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 ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install:node scripts/install.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install 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! /home/vagrant/.npm/_logs/2018-03-01T20_10_11_333Z-debug.logPart of /home/vagrant/.npm/_logs/2018-03-01T20_10_11_333Z-debug.log:
...
36148 info lifecycle [email protected]~install: [email protected]
36149 silly install [email protected]
36150 info lifecycle [email protected]~install: [email protected]
36151 verbose lifecycle [email protected]~install: unsafe-perm in lifecycle false
36152 verbose lifecycle [email protected]~install: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/var/www/apollo/node_modules/node-sass/node_modules/.bin:/var/www/apollo/node_modules/.bin:/home/vagrant/bin:/home/vagrant/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
36153 verbose lifecycle [email protected]~install: CWD: /var/www/apollo/node_modules/node-sass
36154 silly lifecycle [email protected]~install: Args: [ '-c', 'node scripts/install.js' ]
36155 silly lifecycle [email protected]~install: Returned: code: 1 signal: null
36156 info lifecycle [email protected]~install: Failed to exec install script
36157 verbose unlock done using /home/vagrant/.npm/_locks/staging-e5a690960657d9c9.lock for /var/www/apollo/node_modules/.staging
36158 silly saveTree apollo
36158 silly saveTree โโโฌ @fortawesome/[email protected]
36158 silly saveTree โ โโโ @fortawesome/[email protected]
36158 silly saveTree โโโฌ [email protected]
36158 silly saveTree โ โโโฌ [email protected]
36158 silly saveTree โ โ โโโฌ [email protected]
36158 silly saveTree โ โ โโโ [email protected]
...
36158 silly saveTree โ โ โโโ [email protected]
36158 silly saveTree โ โโโ [email protected]
36158 silly saveTree โโโ [email protected]
36158 silly saveTree โโโ popper.[email protected]
36159 warn optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
36160 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
36161 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin
36161 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any
36161 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: linux
36161 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
36162 verbose stack Error: [email protected] install:node scripts/install.js
36162 verbose stack Exit status 1
36162 verbose stack at EventEmitter.(/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
36162 verbose stack at emitTwo (events.js:126:13)
36162 verbose stack at EventEmitter.emit (events.js:214:7)
36162 verbose stack at ChildProcess.(/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
36162 verbose stack at emitTwo (events.js:126:13)
36162 verbose stack at ChildProcess.emit (events.js:214:7)
36162 verbose stack at maybeClose (internal/child_process.js:925:16)
36162 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
36163 verbose pkgid [email protected]
36164 verbose cwd /var/www/apollo
36165 verbose Linux 4.4.0-87-generic
36166 verbose argv "/usr/bin/node" "/usr/bin/npm" "install"
36167 verbose node v8.9.4
36168 verbose npm v5.6.0
36169 error code ELIFECYCLE
36170 error errno 1
36171 error [email protected] install:node scripts/install.js
36171 error Exit status 1
36172 error Failed at the [email protected] install script.
36172 error This is probably not a problem with npm. There is likely additional logging output above.
36173 verbose exit [ 1, true ]Running the same command without sudo or with --unsafe-perm installs the
package without any problems.-
NPM version (npm -v):
5.6.0
-Node version (node -v):
v8.9.4
-Node Process (node -p process.versions):
{ http_parser: '2.7.0',
node: '8.9.4',
v8: '6.1.534.50',
uv: '1.15.0',
zlib: '1.2.11',
ares: '1.10.1-DEV',
modules: '57',
nghttp2: '1.25.0',
openssl: '1.0.2n',
icu: '59.1',
unicode: '9.0',
cldr: '31.0.1',
tz: '2017b' }
-Node Platform (node -p process.platform):
linux
-Node architecture (node -p process.arch):
x64
-node-sass version (node -p "require('node-sass').info"):
--
-npm node-sass versions (npm ls node-sass):
--โ
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/sass/node-sass/issues/2264, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAjZWJRLPQ7v0rBy_1q-uT3Mw4RuahO_ks5taFltgaJpZM4SY8Kh
.
https://github.com/sass/node-sass/blob/master/TROUBLESHOOTING.md#cannot-find-module-rootinstalljs
This helped me
as root
npm install --unsafe-perm
or just for node-sass
npm install --unsafe-perm -g node-sass
from my understanding eventually I need to run this as non-root but ofr now I just want for this to work (temp fix)
Most helpful comment
https://github.com/sass/node-sass/blob/master/TROUBLESHOOTING.md#cannot-find-module-rootinstalljs