Error
cielo@ubuntu:~/go/src/github.com/hyperledger/fabric/blockchain-explorer$ npm install
npm WARN checkPermissions Missing write access to /home/cielo/go/src/github.com/hyperledger/fabric/blockchain-explorer/node_modules
npm ERR! path /home/cielo/go/src/github.com/hyperledger/fabric/blockchain-explorer/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/home/cielo/go/src/github.com/hyperledger/fabric/blockchain-explorer/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/home/cielo/go/src/github.com/hyperledger/fabric/blockchain-explorer/node_modules'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/home/cielo/go/src/github.com/hyperledger/fabric/blockchain-explorer/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/home/cielo/go/src/github.com/hyperledger/fabric/blockchain-explorer/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
╭──────────────────────────────────────╮
│ │
│ Update available 5.6.0 → 6.11.3 │
│ Run npm i -g npm to update │
│ │
╰──────────────────────────────────────╯
npm ERR! A complete log of this run can be found in:
npm ERR! /home/cielo/.npm/_logs/2019-09-17T04_26_10_331Z-debug.log
解决方法
方法一:
sudo
(不建议)
方法二:
更改您的文件权限..像这样
首先检查谁拥有该目录
ls -la /usr/local/lib/node_modules
它拒绝访问,因为node_module文件夹归root所有
drwxr-xr-x 3 root wheel 102 Jun 24 23:24 node_modules
所以这需要通过将root更改为您的用户来更改,但首先运行以下命令以检查当前用户 如何通过OS X中的命令行获取活动用户的名称?
id -un
要么
whoami
然后改变所有者
sudo chown -R [owner]:[owner] /usr/local/lib/node_modules
要么
sudo chown -R ownerName: /usr/local/lib/node_modules
要么
sudo chown -R $USER /usr/local/lib/node_modules
在我这就是:
cielo@ubuntu:~/go/src/github.com/hyperledger/fabric/blockchain-explorer$ sudo chown -R cielo: ~/go/src/github.com/hyperledger/fabric/blockchain-explorer/node_modules
成功截图: