npm install报错:npm ERR! Error: EACCES: permission denied.gyp ERR! configure error

qyh@qyh-mas:/home/wayne/src/frontend$ npm install
npm WARN checkPermissions Missing write access to /home/go/gowork/src/github.com/Qihoo360/wayne/src/frontend/node_modules
npm ERR! path /home/go/gowork/src/github.com/Qihoo360/wayne/src/frontend/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/home/go/gowork/src/github.com/Qihoo360/wayne/src/frontend/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/home/go/gowork/src/github.com/Qihoo360/wayne/src/frontend/node_modules']
npm ERR!   stack:
npm ERR!    "Error: EACCES: permission denied, access '/home/go/gowork/src/github.com/Qihoo360/wayne/src/frontend/node_modules'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path:
npm ERR!    '/home/go/gowork/src/github.com/Qihoo360/wayne/src/frontend/node_modules' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/qyh/.npm/_logs/2019-02-26T00_54_02_493Z-debug.log

--------------------------------------------------------------------------------------------------------------------------------------------------------------

解决方案:

看到这一句提示npm ERR! It is likely you do not have the permissions to access this file as the current user

说明我们没有权限,所以加上sudo运行。但是还是报错:

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/go/gowork/src/github.com/Qihoo360/wayne/src/frontend/node_modules/node-sass/build'
gyp ERR! System Linux 4.18.0-15-generic
gyp ERR! command "/usr/local/bin/node" "/home/go/gowork/src/github.com/Qihoo360/wayne/src/frontend/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/go/gowork/src/github.com/Qihoo360/wayne/src/frontend/node_modules/node-sass
gyp ERR! node -v v11.10.0
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/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] postinstall: `node scripts/build.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

------------------------------------------

方案:升级npm即可。

npm install -g npm

-----------------------------------

我是用下面方法解决的:

npm install --unsafe-perm


即可。

 

你可能感兴趣的:(Linux)