在使用 bower进行安装时获取权限错误

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (21)

每次我尝试用Bower安装某些东西时,都会得到这样的权限错误:

Andreass-MacBook-Air:openMedia Andreas$ bower install jquery
/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:56
            throw err;
                  ^
Error: EACCES, permission denied '/Users/Andreas/.config/configstore/bower-github.yml'
You don't have access to this file.

at Error (native)
at Object.fs.openSync (evalmachine.<anonymous>:500:18)
at Object.fs.readFileSync (evalmachine.<anonymous>:352:15)
at Object.create.all.get (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:34:29)
at Object.Configstore (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:27:44)
at readCachedConfig (/usr/local/lib/node_modules/bower/lib/config.js:22:23)
at defaultConfig (/usr/local/lib/node_modules/bower/lib/config.js:11:24)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/lib/index.js:40:32)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
Andreass-MacBook-Air:openMedia Andreas$ 

提问于
用户回答回答于

尝试sudo?

sudo bower install --allow-root
sudo bower install jquery

另一个解决方案是更改configstore文件夹的chown

sudo chown -R Andreas:Andreas /Users/Andreas/.config/configstore/
bower init
bower install jquery

如果eaccess出现更多错误,请将chown展开到你的整个主文件夹

用户回答回答于

这是修复程序,运行在命令之下。它应该可以工作。

sudo chown -R $USER:$GROUP ~/.npm
sudo chown -R $USER:$GROUP ~/.config

扫码关注云+社区