本人在centos下,用root用户安装了node和npm。
然后安装yo,
npm install -g yo
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
✔ NODE_PATH matches the npm root
Everything looks all right!
+ yo@2.0.0
然而使用yo时,却报错。
[root@localhost address-book]# yo -v
/root/.node/lib/node_modules/yo/node_modules/insight/node_modules/configstore/index.js:53
throw err;
^
Error: EACCES: permission denied, open '/root/.config/configstore/insight-yo.json'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.readFileSync (fs.js:509:33)
at Object.get (/root/.node/lib/node_modules/yo/node_modules/insight/node_modules/configstore/index.js:34:26)
at Object.Configstore.get (/root/.node/lib/node_modules/yo/node_modules/insight/node_modules/configstore/index.js:81:13)
at Insight.get (/root/.node/lib/node_modules/yo/node_modules/insight/lib/index.js:48:22)
at Object.<anonymous> (/root/.node/lib/node_modules/yo/lib/cli.js:194:47)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
google也没有找到答案。。
难道是不能用root用户安装这些?
phpcn_u15822017-06-29 10:11:28
You don't have access to this file.
看样子是没权限访问这个文件
看一下这个文件权限。
ls -al /root/.config/configstore/insight-yo.json
尝试下使用下面的命令重新安装下:
npm install --global yo --allow-root
我想大声告诉你2017-06-29 10:11:28
参见GitHub Issue:
https://github.com/yeoman/yo/...
这里面提到一个可行的方法:用NVM处理。
另外,不建议使用root用户进行npm
包的安装操作,经常会因为是root
用户而出现各种无法预测的问题。