search

Home  >  Q&A  >  body text

node.js - npm 安装 bower 时出错。

以下是命令和报错:

首先我直接按照官方文档进行安装:
[glenn@centos7 imooc]$ npm install bower -g
npm ERR! tar.unpack untar error /home/glenn/.npm/bower/1.7.9/package.tgz
npm ERR! Linux 3.10.0-327.22.2.el7.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "bower" "-g"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! path /usr/local/lib/node_modules/bower
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/bower'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/bower']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/bower',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/bower',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:82:15)' ] }
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/glenn/Web/nodejs/imooc/npm-debug.log

嗯 根据提示可能是权限问题,所以
[glenn@centos7 imooc]$ sudo npm install bower -g
[sudo] password for glenn:
sudo: npm: command not found
然而不行,我看了下路径
[glenn@centos7 imooc]$ whereis npm
npm: /usr/local/bin/npm

然后我 google 了一下,似乎没人遇到这个问题。

天蓬老师天蓬老师2777 days ago559

reply all(3)I'll reply

  • 怪我咯

    怪我咯2017-04-17 14:38:45

    Try itsudo /usr/local/bin/npm install bower -g

    reply
    0
  • 阿神

    阿神2017-04-17 14:38:45

    Try setting NODE_PATH;

    reply
    0
  • 阿神

    阿神2017-04-17 14:38:45

    Permission issue, add sudo

    reply
    0
  • Cancelreply