Ubuntu:错误:EACCES,使用 bower 安装时权限被拒绝错误



我正在使用以下命令安装bower...

sudo npm install -g bower

并获取以下内容...

npm http GET https://registry.npmjs.org/bower
npm http 304 https://registry.npmjs.org/bower
/usr/local/bin/bower -> /usr/local/lib/node_modules/bower/bin/bower
bower@1.7.7 /usr/local/lib/node_modules/bower

我相信鲍尔已经使用NPM成功安装。

然后我运行以下命令来安装一个角度计时器......

bower install angular-timer

并获得以下错误缠身的回溯...

Error: EACCES, permission denied '/home/alopex/.config/configstore/bower-github.yml'
You don't have access to this file.
at Object.fs.openSync (evalmachine.<anonymous>:432:18)
at Object.fs.readFileSync (evalmachine.<anonymous>:286:15)
at Object.create.all.get (/usr/local/lib/node_modules/bower/lib/node_modules/configstore/index.js:34:29)
at Object.Configstore (/usr/local/lib/node_modules/bower/lib/node_modules/configstore/index.js:27:44)
at readCachedConfig (/usr/local/lib/node_modules/bower/lib/config.js:19:23)
at defaultConfig (/usr/local/lib/node_modules/bower/lib/config.js:11:12)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/lib/index.js:16:32)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)

我会尝试只使用sudo,但我从环顾堆栈溢出和 Bower 站点知道 Bower 不是为了使用 sudo 运行的。我怎样才能解决这个困境?

首先执行以下操作。

 sudo bower install --allow-root

然后在终端中运行以下命令

 bower install

有时即使成功安装了 bower.json 文件中包含的所有软件包,它也会显示错误。

通常 bower 本地安装在您的项目目录中,不需要 root 访问权限。

干杯!

最新更新