简体   繁体   English

从Windows命令提示符安装Express时出现错误

[英]Getting error while installing Express from windows command prompt

I have successfully installed nodejs in C:\\Program File. 我已经在C:\\ Program File中成功安装了nodejs。 Nodejs and npm are also working fine by checking version of both. 通过检查两者的版本,Nodejs和npm也可以正常工作。

Description and version info of softwares/hardwares I'm using as below 我正在使用的软件/硬件的描述和版本信息如下

OS:- Windows 7 Enterprise SP1, 64-bit 作业系统: -Windows 7 Enterprise SP1,64位

RAM:- 4GB 内存: -4GB

Nodejs:- version 7.4.0 Node.js:-版本7.4.0

npm:- version 4.0.5 npm:-版本4.0.5

java:- version 1.8.0_121 Java:-版本1.8.0_121

Now while I'm trying to install express from cmd using npm install --save express command,following error is coming. 现在,当我尝试使用npm install --save express命令从cmd npm install --save 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 ]

I already searched it in stack overflow and also get a solution of it but for the linux operating system . 我已经在堆栈溢出中对其进行了搜索,并获得了针对Linux操作系统的解决方案。 So please don't mark this question duplicate as there is no solution for windows OS for this issue 因此,请不要将此问题标记为重复,因为Windows OS没有针对此问题的解决方案

EDIT:- 编辑:-

When I'm trying to run npm install command following error coming 当我尝试运行npm install命令时出现以下错误

D:\ExpressJS Apps\ExpressDemo>npm install
npm WARN express-demo@1.0.0 No repository field.

After searching lots regarding this issue on internet for last 2 days and consulting with my organization's IT expert team and my project mate, I finally resolved this issue. 在过去两天的时间里,在互联网上搜索了很多有关此问题的信息,并咨询了我组织的IT专家团队和我的项目伙伴之后,我终于解决了这个问题。

First of all I'm developing app using node.js and express at my organization that means I'm working behind the corporate firewall. 首先,我正在使用node.js开发应用程序,并在我的组织中表达意见,这意味着我正在公司防火墙后面工作。 That's why I'm getting above issues mention in question section. 这就是为什么我在问题部分提到以上问题的原因。 So, I just follow the below step to resolve it 所以,我只是按照以下步骤来解决它

Open your command prompt and hit the following three command at your cmd. 打开命令提示符,然后在cmd上命中以下三个命令。

npm set config registry "http://registry.npmjs.org/"
npm set config proxy "http://username:password@host:port/"
npm set config strict-ssl false

After entering above 3 command in command prompt , a file, .npmrc , will be created under C:\\user\\your_user_name directory. 在命令提示符下输入上述3条命令后,将在C:\\ user \\ your_user_name目录下创建一个.npmrc文件。

Now I'm able to download and install all the necessary files including express.js from command line. 现在,我可以从命令行下载并安装所有必需的文件,包括express.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM