在ubuntu上安装Yeoman时出错

当我尝试在ubuntu上安装Yeoman时,我收到以下错误.

harsha@harshamv:~$sudo npm install yo -g
[sudo] password for harsha: 
npm http GET https://registry.npmjs.org/yo
npm http 304 https://registry.npmjs.org/yo
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/update-notifier
npm http GET https://registry.npmjs.org/insight
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/sudo-block
npm http GET https://registry.npmjs.org/open/0.0.4
npm http GET https://registry.npmjs.org/chalk
npm http GET https://registry.npmjs.org/findup
npm http GET https://registry.npmjs.org/shelljs
npm http GET https://registry.npmjs.org/yeoman-generator
npm http 304 https://registry.npmjs.org/nopt
npm http 304 https://registry.npmjs.org/update-notifier
npm http 304 https://registry.npmjs.org/insight
npm http 304 https://registry.npmjs.org/lodash
npm http 304 https://registry.npmjs.org/open/0.0.4
npm http 304 https://registry.npmjs.org/findup
npm http 304 https://registry.npmjs.org/chalk
npm http 304 https://registry.npmjs.org/sudo-block
npm http 304 https://registry.npmjs.org/yeoman-generator
npm http 304 https://registry.npmjs.org/shelljs
npm http 304 https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/has-color
npm http GET https://registry.npmjs.org/ansi-styles
npm http GET https://registry.npmjs.org/strip-ansi
npm http GET https://registry.npmjs.org/semver
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/configstore
npm http GET https://registry.npmjs.org/inquirer
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/ansi-styles
npm http GET https://github.com/Filirom1/nopt/tarball/master#pull-request-in-progress
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/cheerio
npm http GET https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/diff
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/underscore.string
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/debug
npm http GET https://registry.npmjs.org/isbinaryfile
npm http GET https://registry.npmjs.org/dargs
npm http GET https://registry.npmjs.org/inquirer
npm http GET https://registry.npmjs.org/iconv-lite
npm http GET https://registry.npmjs.org/findup-sync
npm http GET https://registry.npmjs.org/text-table
npm http GET https://registry.npmjs.org/download
npm http GET https://registry.npmjs.org/file-utils
npm http GET https://registry.npmjs.org/request
npm http GET https://registry.npmjs.org/class-extend
npm http 304 https://registry.npmjs.org/has-color
npm http 304 https://registry.npmjs.org/semver
npm http 304 https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/ansi-styles
npm http 304 https://registry.npmjs.org/strip-ansi
npm http 304 https://registry.npmjs.org/ansi-styles
npm http 304 https://registry.npmjs.org/abbrev
npm http 304 https://registry.npmjs.org/configstore
npm http 304 https://registry.npmjs.org/inquirer
npm http 304 https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/osenv/0.0.3
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/js-yaml
npm http 304 https://registry.npmjs.org/cheerio
npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/diff
npm http 304 https://registry.npmjs.org/underscore.string
npm http 304 https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/cli-color
npm http GET https://registry.npmjs.org/mute-stream/0.0.3
npm http GET https://registry.npmjs.org/qs
npm http GET https://registry.npmjs.org/json-stringify-safe
npm http GET https://registry.npmjs.org/tunnel-agent
npm http GET https://registry.npmjs.org/forever-agent
npm http GET https://registry.npmjs.org/http-signature
npm http GET https://registry.npmjs.org/hawk
npm http GET https://registry.npmjs.org/aws-sign
npm http GET https://registry.npmjs.org/oauth-sign
npm http GET https://registry.npmjs.org/cookie-jar
npm http GET https://registry.npmjs.org/node-uuid
npm http GET https://registry.npmjs.org/form-data
npm http 304 https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/glob
npm http 304 https://registry.npmjs.org/debug
npm http 304 https://registry.npmjs.org/isbinaryfile
npm http 304 https://registry.npmjs.org/dargs
npm http 304 https://registry.npmjs.org/findup-sync
npm http 304 https://registry.npmjs.org/inquirer
npm http 304 https://registry.npmjs.org/iconv-lite
npm http 304 https://registry.npmjs.org/text-table
npm http 304 https://registry.npmjs.org/download
npm http 304 https://registry.npmjs.org/file-utils
npm http 304 https://registry.npmjs.org/request
npm http 304 https://registry.npmjs.org/class-extend
npm http 304 https://registry.npmjs.org/graceful-fs
npm http 304 https://registry.npmjs.org/osenv/0.0.3
npm http GET https://registry.npmjs.org/decompress
npm http GET https://registry.npmjs.org/each-async
npm http GET https://registry.npmjs.org/through2
npm http 304 https://registry.npmjs.org/js-yaml
npm http 304 https://registry.npmjs.org/cli-color
npm http 304 https://registry.npmjs.org/mute-stream/0.0.3
npm http 304 https://registry.npmjs.org/qs
npm http 200 https://github.com/Filirom1/nopt/tarball/master#pull-request-in-progress
npm http 304 https://registry.npmjs.org/json-stringify-safe
npm http GET https://registry.npmjs.org/tough-cookie
npm http GET https://registry.npmjs.org/aws-sign2
npm http 304 https://registry.npmjs.org/http-signature
npm http 304 https://registry.npmjs.org/tunnel-agent
npm http 304 https://registry.npmjs.org/forever-agent
npm http 304 https://registry.npmjs.org/hawk
npm http GET https://registry.npmjs.org/through
npm http GET https://registry.npmjs.org/mute-stream/0.0.4
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/es5-ext
npm http GET https://registry.npmjs.org/memoizee
npm http 304 https://registry.npmjs.org/aws-sign
npm http GET https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/cookie-jar
npm http 304 https://registry.npmjs.org/node-uuid
npm http 304 https://registry.npmjs.org/oauth-sign
npm http GET https://registry.npmjs.org/argparse
npm http GET https://registry.npmjs.org/esprima
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/minimatch
npm http 304 https://registry.npmjs.org/form-data
npm http 304 https://registry.npmjs.org/decompress
npm http 304 https://registry.npmjs.org/each-async
npm http 304 https://registry.npmjs.org/through2
npm http GET https://registry.npmjs.org/combined-stream
npm http 304 https://registry.npmjs.org/tough-cookie
npm http 304 https://registry.npmjs.org/aws-sign2
npm http 304 https://registry.npmjs.org/through
npm http 304 https://registry.npmjs.org/mute-stream/0.0.4
npm http GET https://registry.npmjs.org/tar
npm http GET https://registry.npmjs.org/stream-combiner
npm http GET https://registry.npmjs.org/tempfile
npm http GET https://registry.npmjs.org/adm-zip
npm http GET https://registry.npmjs.org/mout
npm http GET https://registry.npmjs.org/assert-plus/0.1.2
npm http GET https://registry.npmjs.org/asn1/0.1.11
npm http GET https://registry.npmjs.org/ctype/0.5.2
npm http 304 https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/readable-stream
npm http GET https://registry.npmjs.org/xtend
npm http 304 https://registry.npmjs.org/es5-ext
npm http 304 https://registry.npmjs.org/memoizee
npm http 304 https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/argparse
npm http 304 https://registry.npmjs.org/esprima
npm http 304 https://registry.npmjs.org/lodash
npm http 304 https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/CSSselect
npm http GET https://registry.npmjs.org/entities
npm http 304 https://registry.npmjs.org/combined-stream
npm http GET https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/htmlparser2
npm http 304 https://registry.npmjs.org/tar
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/stream-combiner
npm http 304 https://registry.npmjs.org/tempfile
npm http 304 https://registry.npmjs.org/mout
npm http 304 https://registry.npmjs.org/adm-zip
npm http 304 https://registry.npmjs.org/assert-plus/0.1.2
npm http GET https://registry.npmjs.org/sntp
npm http GET https://registry.npmjs.org/boom
npm http GET https://registry.npmjs.org/hoek
npm http GET https://registry.npmjs.org/cryptiles
npm http GET https://registry.npmjs.org/punycode
npm http GET https://registry.npmjs.org/uuid
npm http GET https://registry.npmjs.org/delayed-stream/0.0.5
npm http 304 https://registry.npmjs.org/ctype/0.5.2
npm http GET https://registry.npmjs.org/duplexer
npm http 304 https://registry.npmjs.org/asn1/0.1.11
npm http 304 https://registry.npmjs.org/readable-stream
npm http 304 https://registry.npmjs.org/xtend
npm http 304 https://registry.npmjs.org/CSSselect
npm http GET https://registry.npmjs.org/event-emitter
npm http GET https://registry.npmjs.org/next-tick
npm http GET https://registry.npmjs.org/underscore
npm http 304 https://registry.npmjs.org/entities
npm http 304 https://registry.npmjs.org/underscore
npm http GET https://registry.npmjs.org/object-keys
npm http 304 https://registry.npmjs.org/lru-cache
npm http 304 https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/htmlparser2
npm http 304 https://registry.npmjs.org/boom
npm http GET https://registry.npmjs.org/string_decoder
npm http 304 https://registry.npmjs.org/sntp
npm http GET https://registry.npmjs.org/fstream
npm http GET https://registry.npmjs.org/block-stream
npm http 304 https://registry.npmjs.org/punycode
npm http 304 https://registry.npmjs.org/hoek
npm http 304 https://registry.npmjs.org/cryptiles
npm WARN package.json punycode@1.2.3 No README.md file found!
npm http 304 https://registry.npmjs.org/uuid
npm http 304 https://registry.npmjs.org/delayed-stream/0.0.5
npm http 304 https://registry.npmjs.org/duplexer
npm http 304 https://registry.npmjs.org/event-emitter
npm http 304 https://registry.npmjs.org/next-tick
npm http 304 https://registry.npmjs.org/object-keys
npm http 304 https://registry.npmjs.org/underscore
npm http 304 https://registry.npmjs.org/string_decoder
npm http 304 https://registry.npmjs.org/fstream
npm http GET https://registry.npmjs.org/domhandler
npm http GET https://registry.npmjs.org/domutils
npm http GET https://registry.npmjs.org/domelementtype
npm http GET https://registry.npmjs.org/CSSwhat
npm http 304 https://registry.npmjs.org/block-stream
npm http 304 https://registry.npmjs.org/domhandler
npm http 304 https://registry.npmjs.org/domutils
npm http 304 https://registry.npmjs.org/domelementtype
npm http 304 https://registry.npmjs.org/CSSwhat
npm http GET https://registry.npmjs.org/core-util-is
npm http GET https://registry.npmjs.org/debuglog/0.0.2
npm http 304 https://registry.npmjs.org/core-util-is
npm http 304 https://registry.npmjs.org/debuglog/0.0.2
/usr/local/bin/yo -> /usr/local/lib/node_modules/yo/cli.js

> yo@1.1.2 postinstall /usr/local/lib/node_modules/yo
> node ./scripts/doctor

sh: 1: node: not found
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! yo@1.1.2 postinstall: `node ./scripts/doctor`
npm ERR! `sh "-c" "node ./scripts/doctor"` failed with 127
npm ERR! 
npm ERR! Failed at the yo@1.1.2 postinstall script.
npm ERR! This is most likely a problem with the yo package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./scripts/doctor
npm ERR! You can get their info via:
npm ERR!     npm owner ls yo
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.11.0-15-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "yo" "-g"
npm ERR! cwd /home/harsha
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/harsha/npm-debug.log
npm ERR! not ok code 0

编辑

尝试MortezaLSC的解决方案后 – 我收到以下错误

npm http 304 https://registry.npmjs.org/amdefine
/usr/local/bin/bower -> /usr/local/lib/node_modules/bower/bin/bower
/usr/local/bin/yo -> /usr/local/lib/node_modules/yo/cli.js

> yo@1.1.2 postinstall /usr/local/lib/node_modules/yo
> node ./scripts/doctor

sh: 1: node: not found
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! yo@1.1.2 postinstall: `node ./scripts/doctor`
npm ERR! `sh "-c" "node ./scripts/doctor"` failed with 127
npm ERR! 
npm ERR! Failed at the yo@1.1.2 postinstall script.
npm ERR! This is most likely a problem with the yo package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./scripts/doctor
npm ERR! You can get their info via:
npm ERR!     npm owner ls yo
npm ERR! There is likely additional logging output above.

npm ERR! System Linux 3.11.0-15-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "yo" "grunt-cli" "bower"
npm ERR! cwd /usr/local/share
npm ERR! node -v v0.10.15
npm ERR! npm -v 1.2.18
npm ERR! code ELIFECYCLE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /usr/local/share/npm-debug.log
npm ERR! not ok code 0
最佳答案
我在Ubuntu 12.04和CentOS 6上遇到了类似的各种问题.我在两者上都运行了最新版本的npm,但没有运气 – 很多错误.

经过大量的谷歌搜索,apt-getting和yumming终于让我升级节点本身.见这个answer on upgrading,即:

sudo npm install n -g
sudo n stable

之后我又回到了:

sudo npm install -g yo

它在两个操作系统上都安装得很好!

好吧,在CentOS上我也必须去我的主目录并执行:

sudo chmod -R myusername .npm

(.npm及其下的所有内容都由root拥有,在运行yo生成器时会造成麻烦).

转载注明原文:在ubuntu上安装Yeoman时出错 - 代码日志