npm install 报错 stack Error: EACCES: permission denied

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/cql08e/article/details/82704364
###  npm install时报错:
[root@localhost ~]# npm install
........
........
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] | linux | 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` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import sys; print "2.7.5
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node version: 8.11.4
gyp verb command install [ '8.11.4' ]
gyp verb install input version string "8.11.4"
gyp verb install installing version: 8.11.4
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.11.4
gyp verb ensuring nodedir is created /root/.node-gyp/8.11.4
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/8.11.4"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/var/lib/jenkins/workspace/project_name/node_modules/node-sass/.node-gyp"
gyp verb tmpdir == cwd automatically will remove dev files after to save disk space
gyp verb command install [ '--node_gyp_internal_noretry', '8.11.4' ]
gyp verb install input version string "8.11.4"
gyp verb install installing version: 8.11.4
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 8.11.4
gyp verb ensuring nodedir is created /var/lib/jenkins/workspace/project_name/node_modules/node-sass/.node-gyp/8.11.4
gyp WARN install got an error, rolling back install
gyp verb command remove [ '8.11.4' ]
gyp verb remove using node-gyp dir: /var/lib/jenkins/workspace/project_name/node_modules/node-sass/.node-gyp
gyp verb remove removing target version: 8.11.4
gyp verb remove removing development files for version: 8.11.4
gyp WARN install got an error, rolling back install
gyp verb command remove [ '8.11.4' ]
gyp verb remove using node-gyp dir: /var/lib/jenkins/workspace/project_name/node_modules/node-sass/.node-gyp
gyp verb remove removing target version: 8.11.4
gyp verb remove removing development files for version: 8.11.4
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/var/lib/jenkins/workspace/project_name/node_modules/node-sass/.node-gyp'
gyp ERR! System Linux 3.10.0-514.el7.x86_64
gyp ERR! command "/home/software/node/bin/node" "/var/lib/jenkins/workspace/project_name/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /var/lib/jenkins/workspace/project_name/node_modules/node-sass
gyp ERR! node -v v8.11.4
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
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] 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!     /root/.npm/_logs/2018-09-14T07_44_42_956Z-debug.log

修改node_modules/node-sass/.node-gyp目录权限为777,无效,仍然报错

解决办法:
sudo npm install
                                             

猜你喜欢

转载自blog.csdn.net/cql08e/article/details/82704364