1

当我执行以下命令时

npm install request

输出是:

bash: npm: command not found
4

2 回答 2

1

安装npm

通过

sudo curl http://npmjs.org/install.sh | sh

然后运行

npm install request
于 2012-07-29T09:53:52.353 回答
0

对于终端安装请求模块:

npm install request

以下是输出

npm http GET https://registry.npmjs.org/request
npm ERR! Error: failed to fetch from registry: request
npm ERR!     at /opt/node0610/lib/node_modules/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR!     at cb (/opt/node0610/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:32:9)
npm ERR!     at Request._callback (/opt/node0610/lib/node_modules/npm/lib/utils /npm-registry-client/request.js:137:18)
npm ERR!     at Request.callback (/opt/node0610/lib/node_modules/npm/node_modules/request/main.js:109:22)
npm ERR!     at Request.<anonymous> (/opt/node0610/lib/node_modules/npm/node_modules/request/main.js:198:58)
npm ERR!     at Request.emit (events.js:88:20)
npm ERR!     at ClientRequest.<anonymous> (/opt/node0610/lib/node_modules/npm/node_modules/request/main.js:195:10)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at CleartextStream.<anonymous> (http.js:1134:11)
npm ERR!     at CleartextStream.emit (events.js:67:17)
npm ERR! You may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>
npm ERR! 
npm ERR! System Linux 2.6.18-194.el5
npm ERR! command "node" "/opt/node0610/bin/npm" "install" "request"
npm ERR! cwd /home/applmgr
npm ERR! node -v v0.6.10
npm ERR! npm -v 1.1.0-3
npm ERR! message failed to fetch from registry: request
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/applmgr/npm-debug.log
npm not ok

文件 /home/applmgr/npm-debug.log 的内容

info it worked if it ends with ok
verbose cli [ 'node', '/opt/node0610/bin/npm', 'install', 'request' ]
info using npm@1.1.0-3
info using node@v0.6.10
verbose config file /home/applmgr/.npmrc
verbose config file /opt/node0610/etc/npmrc
verbose config file /opt/node0610/lib/node_modules/npm/npmrc
verbose cache add [ 'request', null ]
silly cache add: name, spec, args [ undefined, 'request', [ 'request', null ] ]
verbose parsed url { pathname: 'request', path: 'request', href: 'request' }
verbose addNamed [ 'request', '' ]
verbose addNamed [ null, '' ]
silly name, range, hasData [ 'request', '', false ]
verbose raw, before any munging request
verbose url resolving [ 'https://registry.npmjs.org/', './request' ]
verbose url resolved https://registry.npmjs.org/request
http GET https://registry.npmjs.org/request
ERR! Error: failed to fetch from registry: request
ERR!     at /opt/node0610/lib/node_modules/npm/lib/utils/npm-registry-client/get.js:139:12
ERR!     at cb (/opt/node0610/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:32:9)
ERR!     at Request._callback (/opt/node0610/lib/node_modules/npm/lib/utils/npm-registry-client/request.js:137:18)
ERR!     at Request.callback (/opt/node0610/lib/node_modules/npm/node_modules/request/main.js:109:22)
ERR!     at Request.<anonymous> (/opt/node0610/lib/node_modules/npm/node_modules/request/main.js:198:58)
ERR!     at Request.emit (events.js:88:20)
ERR!     at ClientRequest.<anonymous> (/opt/node0610/lib/node_modules/npm/node_modules/request/main.js:195:10)
ERR!     at ClientRequest.emit (events.js:67:17)
ERR!     at CleartextStream.<anonymous> (http.js:1134:11)
ERR!     at CleartextStream.emit (events.js:67:17)
ERR! You may report this log at:
ERR!     <http://github.com/isaacs/npm/issues>
ERR! or email it to:
ERR!     <npm-@googlegroups.com>
ERR! 
ERR! System Linux 2.6.18-194.el5
ERR! command "node" "/opt/node0610/bin/npm" "install" "request"
ERR! cwd /home/applmgr
ERR! node -v v0.6.10
ERR! npm -v 1.1.0-3
ERR! message failed to fetch from registry: request
verbose exit [ 1, true ]
于 2012-07-29T10:29:28.003 回答