node.js - centos7 root用戶,用npm安裝yo,yo是不是不能用?
世界只因有你
世界只因有你 2017-06-29 10:09:28
0
3
1264

本人在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使用者安裝這些?

世界只因有你
世界只因有你

全部回覆(3)
phpcn_u1582

You don't have access to this file.
看樣子是沒權限存取這個檔案

看一下這個檔案權限。

ls -al /root/.config/configstore/insight-yo.json

嘗試下使用下面的指令重新安裝下:

npm install --global yo --allow-root
滿天的星座

我在Ubuntu下, 和樓主報一樣的錯。 有大神 ,來解答下。 改訪問權限的辦法,走不通。

我想大声告诉你

參見GitHub Issue:

https://github.com/yeoman/yo/...

這裡面提到一個可行的方法:用NVM處理。

另外,不建議使用root使用者進行npm套件的安裝操作,常常會因為是root用戶而出現各種無法預測的問題。

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!