我已在C:\ Program File中成功安装了nodejs。通过检查两者的版本,Nodejs和npm也正常工作。
我使用的软件/硬件的说明和版本信息如下
操作系统: - Windows 7 Enterprise SP1,64位
RAM: - 4GB
Nodejs: - 版本7.4.0
npm: - 版本4.0.5
java: - 版本1.8.0_121
现在,当我尝试使用 npm install --save express
命令从cmd安装express时,会出现以下错误。
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '--save',
1 verbose cli 'express' ]
2 info using npm@4.0.5
3 info using node@v7.4.0
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData express
8 silly fetchNamedPackageData express
9 silly mapToRegistry name express
10 silly mapToRegistry using default registry
11 silly mapToRegistry registry https://registry.npmjs.org/
12 silly mapToRegistry data Result {
12 silly mapToRegistry raw: 'express',
12 silly mapToRegistry scope: null,
12 silly mapToRegistry escapedName: 'express',
12 silly mapToRegistry name: 'express',
12 silly mapToRegistry rawSpec: '',
12 silly mapToRegistry spec: 'latest',
12 silly mapToRegistry type: 'tag' }
13 silly mapToRegistry uri https://registry.npmjs.org/express
14 verbose request uri https://registry.npmjs.org/express
15 verbose request no auth needed
16 info attempt registry request try #1 at 7:15:42 PM
17 verbose request id 90eb0dc94f842d2f
18 http request GET https://registry.npmjs.org/express
19 info retry will retry, error on last attempt: Error: getaddrinfo EAI_AGAIN registry.npmjs.org:443
20 info attempt registry request try #2 at 7:15:52 PM
21 http request GET https://registry.npmjs.org/express
22 info retry will retry, error on last attempt: Error: getaddrinfo EAI_AGAIN registry.npmjs.org:443
23 info attempt registry request try #3 at 7:16:52 PM
24 http request GET https://registry.npmjs.org/express
25 silly fetchPackageMetaData Error: getaddrinfo EAI_AGAIN registry.npmjs.org:443
25 silly fetchPackageMetaData at Object.exports._errnoException (util.js:1022:11)
25 silly fetchPackageMetaData at errnoException (dns.js:33:15)
25 silly fetchPackageMetaData at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
25 silly fetchPackageMetaData error for express { Error: getaddrinfo EAI_AGAIN registry.npmjs.org:443
25 silly fetchPackageMetaData at Object.exports._errnoException (util.js:1022:11)
25 silly fetchPackageMetaData at errnoException (dns.js:33:15)
25 silly fetchPackageMetaData at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
25 silly fetchPackageMetaData code: 'EAI_AGAIN',
25 silly fetchPackageMetaData errno: 'EAI_AGAIN',
25 silly fetchPackageMetaData syscall: 'getaddrinfo',
25 silly fetchPackageMetaData hostname: 'registry.npmjs.org',
25 silly fetchPackageMetaData host: 'registry.npmjs.org',
25 silly fetchPackageMetaData port: 443 }
26 silly rollbackFailedOptional Starting
27 silly rollbackFailedOptional Finishing
28 silly runTopLevelLifecycles Finishing
29 silly install printInstalled
30 verbose stack Error: getaddrinfo EAI_AGAIN registry.npmjs.org:443
30 verbose stack at Object.exports._errnoException (util.js:1022:11)
30 verbose stack at errnoException (dns.js:33:15)
30 verbose stack at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
31 verbose cwd D:\ExpressJS Apps\ExpressDemo
32 error Windows_NT 6.1.7601
33 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "express"
34 error node v7.4.0
35 error npm v4.0.5
36 error code EAI_AGAIN
37 error errno EAI_AGAIN
38 error syscall getaddrinfo
39 error getaddrinfo EAI_AGAIN registry.npmjs.org:443
40 error If you need help, you may report this error at:
40 error <https://github.com/npm/npm/issues>
41 verbose exit [ 1, true ]
我已经在堆栈溢出中搜索了它,并且还获得了它的解决方案,但是对于 linux操作系统。所以请不要将此问题标记为重复,因为 Windows操作系统没有针对此问题的解决方案
修改: -
当我试图在出现错误后运行npm install
命令时
D:\ExpressJS Apps\ExpressDemo>npm install
npm WARN express-demo@1.0.0 No repository field.
答案 0 :(得分:0)
在过去2天在互联网上搜索有关此问题的批次并咨询我的组织的IT专家团队和我的项目伙伴后,我终于解决了这个问题。
首先,我使用node.js开发应用程序并在我的组织中表达,这意味着我在公司防火墙后面工作。这就是我在问题部分提到上述问题的原因。所以,我只需按照以下步骤解决它
打开命令提示符并在cmd处按下以下三个命令。
npm set config registry "http://registry.npmjs.org/"
npm set config proxy "http://username:password@host:port/"
npm set config strict-ssl false
在命令提示符下输入3以上命令后,将在 C:\ user \ your_user_name 目录下创建 .npmrc 文件。
现在,我可以从命令行下载并安装所有必要的文件,包括 express.js 。