Help us understand the problem. What is going on with this article?

npm installでError:EACCESがでたら

More than 3 years have passed since last update.

例:Bowerのインストール

npm install -g bower
npm ERR! tar.unpack untar error /Users/Foo/.npm/bower/1.4.1/package.tgz
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "bower"
npm ERR! node v0.12.3
npm ERR! npm  v2.9.1
npm ERR! path /usr/local/lib/node_modules/bower
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/bower']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
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:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR!      'FSReqWrap.oncomplete (fs.js:95: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!     /Users/Foo/.npm/npm-debug.log

解決方法1 chmodで権限を与える

解決コマンド
sudo chmod 777 /usr/local/lib;sudo chmod 777 /usr/local/lib/node_modules
※777の意味などは自分で調べましょう

ディレクトリを作成する権限がないため、このエラーが起きています。
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/bower'
と書いてるように、/usr/local/lib か /usr/local/lib/node_modules に権限がないことが分かります。
したがって、その2つのディレクトリに権限を付与します。
※node_modulesディレクトリは存在しないこともあるので、その場合はコマンド失敗しても大丈夫です

解決方法2 sudoで実行

解決コマンド
sudo npm install -g bower

インストール系のコマンドに失敗した場合、大体対策が出力されます

"Please try running this command again as root/Administrator."とあるように、
rootもしくはAdministratorで実行してくださいと書いてあります。

Gaddict
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした