当前位置:  开发笔记 > 编程语言 > 正文

Node.js npm install express无法从注册表中获取

如何解决《Node.jsnpminstallexpress无法从注册表中获取》经验,为你挑选了2个好方法。

我正在启动我的第一个Node.js服务器.我试图遵循Node.js中的教程.

安装了Node.js并执行后npm install,下一条指令是通过运行启动服务器,node server.js这会产生以下错误:

node.js:201
    throw e; // process.nextTick error, or 'error' event on first tick
          ^
Error: Cannot find module 'express'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object. (/home/sisko/Desktop/ExerciseFiles/01/03/start/server.js:1:77)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:32)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:479:10)
sisko@VirtualBox:~/Desktop/ExerciseFiles/01/03/start$ 

它似乎需要一个名为express的模块,所以我环顾四周,找到了npm install express应该解决问题的命令.但是,我收到以下错误:

sisko@VirtualBox:~/Desktop/ExerciseFiles/01/03/start$ npm install express

npm http GET https://registry.npmjs.org/express

npm ERR! Error: failed to fetch from registry: express
npm ERR!     at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR!     at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR!     at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
npm ERR!     at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR!     at Request. (/usr/lib/nodejs/request/main.js:212:58)
npm ERR!     at Request.emit (events.js:88:20)
npm ERR!     at ClientRequest. (/usr/lib/nodejs/request/main.js:412:12)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at HTTPParser.onIncoming (http.js:1261:11)
npm ERR!     at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR! You may report this log at:
npm ERR!     
npm ERR! or use
npm ERR!     reportbug --attach /home/sisko/Desktop/ExerciseFiles/01/03/start/npm-debug.log npm
npm ERR! 
npm ERR! System Linux 3.2.0-52-generic
npm ERR! command "node" "/usr/bin/npm" "install" "express"
npm ERR! cwd /home/sisko/Desktop/ExerciseFiles/01/03/start
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: express
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/sisko/Desktop/ExerciseFiles/01/03/start/npm-debug.log
npm not ok

bakkal.. 89

对于一些npm config set registry http://registry.npmjs.org/以前运行的人npm install express似乎解决了这个问题



1> bakkal..:

对于一些npm config set registry http://registry.npmjs.org/以前运行的人npm install express似乎解决了这个问题


当我在安装不同的软件包安装时遇到同样的问题时,这对我有用,即clevertech-cli.这不仅仅是为了快递.

2> hegemon..:

这有助于作为接受答案的替代解决方案:

npm config set strict-ssl false

npm的问题是无法正确识别默认注册表ssl证书.

推荐阅读
小白也坚强_177
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有