使用 Bower 安装时出现权限错误
Getting a permission error when installing with 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/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$
我想可能有一个简单的解决方案。但这是我第一次使用 Bower。提前致谢。
尝试过 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
您只需将其复制并粘贴到您的终端即可
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
}
每次我尝试使用 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$
我想可能有一个简单的解决方案。但这是我第一次使用 Bower。提前致谢。
尝试过 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
您只需将其复制并粘贴到您的终端即可
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
}