Permissions 使用bower安装时出现权限错误

Permissions 使用bower安装时出现权限错误,permissions,installation,bower,Permissions,Installation,Bower,每次我尝试使用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/An

每次我尝试使用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$ 
Andreass MacBook Air:openMedia Andreas$bower安装jquery /usr/local/lib/node_modules/bower/node_modules/configstore/index.js:56 犯错误; ^ 错误:EACCES,权限被拒绝“/Users/Andreas/.config/configstore/bower github.yml” 您没有访问此文件的权限。 错误(本机) 在Object.fs.openSync(evalmachine.:500:18) 在Object.fs.readFileSync(evalmachine:352:15) 在Object.create.all.get(/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:34:29) 在Object.Configstore(/usr/local/lib/node_modules/bower/node_modules/Configstore/index.js:27:44) 在readCachedConfig(/usr/local/lib/node\u modules/bower/lib/config.js:22:23) 在defaultConfig(/usr/local/lib/node_modules/bower/lib/config.js:11:24) 反对。(/usr/local/lib/node_modules/bower/lib/index.js:40:32) 在模块处编译(Module.js:460:26) 在Object.Module.\u extensions..js(Module.js:478:10) Andreas MacBook Air:openMedia Andreas$ 我想可能有一个简单的解决办法。但这是我第一次接触鲍尔。提前谢谢。

试过sudo吗

sudo bower install --allow-root
sudo bower install jquery
另一个解决方案是更改configstore文件夹的目录

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

你可以把它复制粘贴到你的终端上

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

更改json bower配置文件.bowerrc,如下所示

{
    "directory": "www/lib"
}

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

第一个是可行的,但我在代码包中也遇到了一些错误,使用sudo并没有解决我所有的问题。但是,更改configstore的chown确实做到了!谢谢你,阿约沙!第二种解决方案是最好的。周-R.~/。config/configstore您还可以使用用户别名:sudo chown-R$user~/.config,sudo chown-R$user~/.cachesudo如果要正确管理系统,则会导致更多权限错误IMO@f-请原谅我的无知,你能解释一下在哪里执行这些命令吗?我在项目的根目录下使用命令提示符,这表明“sudo”未被识别为内部或外部命令。您使用的是哪个操作系统?sudo是Unix特定的命令,Windows不支持。如果您试图在Windows机器上安装bower,我建议您使用git Windows bash,它提供了用于从命令行运行git的bash仿真,以及用于使用git和Shell集成的图形用户界面。