node.js - 在 Ubuntu 上安装 Bower 版本 1.8.2 时出错

标签 node.js bower npm-install bower-install

我正在尝试安装 Bower 版本 1.8.2
在我的 Ubuntu 16.04 上全局运行

但它显示缺少写入权限/usr/local/bin

我有 Node 4.2.6 和 npm 3.5.2 我收到这个错误:

 ubuntu@ubuntu-Inspiron-3521:~/Desktop/Python-2.7.14$ npm install -g bower
npm WARN deprecated bower@1.8.2: ...psst! Your project can stop working at any moment because its dependencies can change. Prevent this by migrating to Yarn: https://bower.io/blog/2017/how-to-migrate-away-from-bower/
npm WARN checkPermissions Missing write access to /usr/local/lib
/usr/local/lib
`-- bower@1.8.2 

npm ERR! Linux 4.4.0-21-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "bower"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! path /usr/local/lib
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/local/lib'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ubuntu/Desktop/Python-2.7.14/npm-debug.log
ubuntu@ubuntu-Inspiron-3521:~/Desktop/Python-2.7.14$ node --version
v4.2.6
ubuntu@ubuntu-Inspiron-3521:~/Desktop/Python-2.7.14$ npm --version
3.5.2
ubuntu@ubuntu-Inspiron-3521:~/Desktop/Python-2.7.14$ 

最佳答案

您可以使用 sudo 安装它:

sudo npm i --global bower

但不建议这样做,因此您可以像这样修复 npm 权限:

sudo chown -R $(whoami) $(npm config get prefix)/lib/node_modules

您可以找到gist for the same here.

关于node.js - 在 Ubuntu 上安装 Bower 版本 1.8.2 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49133165/

相关文章:

bower - 为什么要检查 bower 组件?

javascript - 如何使用 AngularJS 和 Bootstrap 将 ngTagsInput 导入到您的项目中?

azure - 无法在 Linux 上的 Azure 应用服务上安装 "npm install -g botdispatch"

node.js - NodeJS 渲染 html 文件,其表单在 Angular 侧不起作用

javascript - 在 Node.js 中禁用 GC

node.js - Node.js 中的子进程是否可以保留彩色输出?

javascript - 设置 Yeoman——多个 bower_components

npm - 从 Bower(已停产)改为使用 Yarn/Npm(.Net Core MVC)VS2017

node.js - 如何从 puppeteer 中抓取 JSON?

node.js - Apache Cordova 在 Yosemite 上安装失败