【问题标题】:Trouble shoot NPM in NodeJSNode JS 中的 NPM 疑难解答
【发布时间】:2012-07-29 18:29:28
【问题描述】:

当我执行以下命令时

npm install request

输出是:

bash: npm: command not found

【问题讨论】:

    标签: linux node.js 64-bit npm oracle-enterprise-linux


    【解决方案1】:

    安装npm

    通过

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

    然后运行

    npm install request
    

    【讨论】:

    • 路径有问题,安装了npm,修改路径后用命令“npm --version”1.1.0-3得到版本
    • 我无法安装请求模块
    • 这个链接github.com/isaacs/npm/issues/2119解决了我的问题。我必须执行以下命令:npm config set registry http://registry.npmjs.org/ 现在我可以安装任何 npm 包
    【解决方案2】:

    为终端安装请求模块:

    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 ]
    

    【讨论】:

      猜你喜欢
      • 2013-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-06
      • 2014-08-29
      • 2011-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多