Getting a permission error when installing with bower

旧街凉风 提交于 2019-11-28 17:15:20

问题


Everytime I try to install something with Bower I get a permission error like this:

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$ 

I imagine there might be an easy solution to this. But this is my first experience with Bower. Thanks in advance.


回答1:


Tried with sudo ?

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

Another solution is to change the chown of your configstore folder

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

If there are more errors with eaccess, expand the chown to your whole home folder




回答2:


Here is the fix, run below commands. it should work.

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



回答3:


Change the json bower configuration file .bowerrc which looks like

{
    "directory": "www/lib"
}

to look like

{
    "directory": "www/lib",
    "allow_root": true
}



回答4:


you can just copy and paste this on your terminal

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}


来源:https://stackoverflow.com/questions/29865913/getting-a-permission-error-when-installing-with-bower

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!