症状
$ npm install -g yo
npm http GET https://registry.npmjs.org/yo
npm http 304 https://registry.npmjs.org/yo
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/yo'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/yo']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/yo',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/yo',
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:37:53',
npm ERR! 'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
(*;-;)? < sudo npm install -g yo
sudo: npm: command not found
対応: npmをインストールをします
ダメ
(*;-;)? < curl https://npmjs.org/install.sh | sudo sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
193 193 193 193 0 0 22 0 0:00:08 0:00:08 --:--:-- 269
sh: line 1: html: No such file or directory
sh: line 2: syntax error near unexpected token `<'
'h: line 2: `<head><title>301 Moved Permanently</title></head>
いい
(*;-;)? < wget http://npmjs.org/install.sh
--2014-12-06 07:59:20-- http://npmjs.org/install.sh
Resolving npmjs.org... 54.187.170.181
Connecting to npmjs.org|54.187.170.181|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www.npmjs.org/install.sh [following]
--2014-12-06 07:59:27-- https://www.npmjs.org/install.sh
Resolving www.npmjs.org... 103.245.222.162
Connecting to www.npmjs.org|103.245.222.162|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 6044 (5.9K) [application/x-sh]
Saving to: `install.sh'
100%[================================================================================================>] 6,044 2.81K/s in 2.1s
2014-12-06 07:59:38 (2.81 KB/s) - `install.sh' saved [6044/6044]
(*'-') < sh ./install.sh
tar=/bin/tar
version:
tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-2.1.11.tgz
unbuild npm@1.3.24
> npm@2.1.11 prepublish /tmp/npm.4916/package
> node bin/npm-cli.js prune --prefix=. --no-global && rm -rf test/*/*/node_modules && make -j8 doc
make: Nothing to be done for `doc'.
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm@2.1.11 /usr/local/lib/node_modules/npm
It worked
インストールファイルをローカルに落としてから展開するとうまくいきました。
試しに
(*;-;)? < npm install -g yo grunt-cli bower
/usr/local/bin/yo -> /usr/local/lib/node_modules/yo/cli.js
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
/usr/local/bin/yo -> /usr/local/lib/node_modules/yo/cli.js
> yo@1.3.3 postinstall /usr/local/lib/node_modules/yo
> yodoctor
[Yeoman Doctor] Everything looks all right!
/usr/local/bin/bower -> /usr/local/lib/node_modules/bower/bin/bower
なんかうまくいったっぽい。