我正在尝试通过npm安装不同的模块。
c:\>npm install -g express
但我收到以下错误消息:
0 info it worked if it ends with ok
1 verbose cli [ 'D:\\FH Kiel\\WS 13\\Advanced Javascript\\nodejs\\\\node.exe',
1 verbose cli 'D:\\FH Kiel\\WS 13\\Advanced Javascript\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli 'express' ]
2 info using npm@1.3.14
3 info using node@v0.10.22
4 verbose node symlink D:\FH Kiel\WS 13\Advanced Javascript\nodejs\\node.exe
5 verbose cache add [ 'express', null ]
6 verbose cache add name=undefined spec="express" args=["express",null]
7 verbose parsed url { protocol: null,
7 verbose parsed url slashes: null,
7 verbose parsed url auth: null,
7 verbose parsed url host: null,
7 verbose parsed url port: null,
7 verbose parsed url hostname: null,
7 verbose parsed url hash: null,
7 verbose parsed url search: null,
7 verbose parsed url query: null,
7 verbose parsed url pathname: 'express',
7 verbose parsed url path: 'express',
7 verbose parsed url href: 'express' }
8 silly lockFile f3c62de4-express express
9 verbose lock express C:\Users\MW\AppData\Roaming\npm-cache\f3c62de4-express.lock
10 silly lockFile f3c62de4-express express
11 silly lockFile f3c62de4-express express
12 verbose addNamed [ 'express', '' ]
13 verbose addNamed [ null, '*' ]
14 silly lockFile 64a534c1-express express@
15 verbose lock express@ C:\Users\MW\AppData\Roaming\npm-cache\64a534c1-express.lock
16 silly addNameRange { name: 'express', range: '*', hasData: false }
17 verbose url raw express
18 verbose url resolving [ 'http://registry.npmjs.org/', './express' ]
19 verbose url resolved http://registry.npmjs.org/express
20 info trying registry request attempt 1 at 15:47:46
21 http GET http://registry.npmjs.org/express
22 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND
23 info trying registry request attempt 2 at 15:47:59
24 http GET http://registry.npmjs.org/express
25 info retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND
26 info trying registry request attempt 3 at 15:49:01
27 http GET http://registry.npmjs.org/express
28 silly lockFile 64a534c1-express express@
29 silly lockFile 64a534c1-express express@
30 error network getaddrinfo ENOTFOUND
30 error network This is most likely not a problem with npm itself
30 error network and is related to network connectivity.
30 error network In most cases you are behind a proxy or have bad network settings.
30 error network
30 error network If you are behind a proxy, please make sure that the
30 error network 'proxy' config is set properly. See: 'npm help config'
31 error System Windows_NT 6.1.7601
32 error command "D:\\FH Kiel\\WS 13\\Advanced Javascript\\nodejs\\\\node.exe" "D:\\FH Kiel\\WS 13\\Advanced Javascript\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "express"
33 error cwd D:\nodejs
34 error node -v v0.10.22
35 error npm -v 1.3.14
36 error syscall getaddrinfo
37 error code ENOTFOUND
38 error errno ENOTFOUND
39 verbose exit [ 1, true ]
我尝试了以下解决方案:
npm config set proxy http://usr:pwd@proxyname:port
npm config set https-proxy http://usr:pwd@proxyname:port
npm config set registry http://registry.npmjs.org/
我已经禁用防火墙并尝试了......没有任何工作......没有代理设置所以这应该可以工作(并且在其他计算机上工作)...我已经安装了node.js而没有任何问题。< / p>
感谢名单。
更新:这是Windows主机文件:
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 localhost
我也尝试过在其他帖子中找到的解决方案:
npm install <packagename> --registry http://registry.npmjs.org/
也没有工作:(
答案 0 :(得分:13)
我没有找到任何解决方案,但最后我不得不重新安装我的Windows。它现在正在运作......
答案 1 :(得分:1)
删除在npm配置文件中设置的所有代理。
在命令提示符下,键入npm config edit
这将在文本编辑器中打开您的 .npmrc 配置文件。
在此文件中,转到代理设置,然后在其中输入您尚未配置的设置(例如http://proxyurl/:port
),删除这些设置,保存文件,然后从那里进行设置。这通常可以解决此问题。
答案 2 :(得分:0)
在我的情况下,问题是设置https-proxy但是没有找到办法。最后,我在命令提示符下尝试了以下内容,
npm config edit
它打开了 .npmrc 文件,其中包含以冒号注释的默认选项列表。只需在https-proxy之前删除冒号并输入我公司提供给我的冒号,在编辑器中点击保存,一切正常。
希望它有所帮助。
答案 3 :(得分:0)
我也有globall代理。在您的PC上找到该路径。
C:\Users\(Your Username)\AppData\Roaming\npm\etc\
find that file > npmignore
(edit with text editor and than remove proxy lines.)
之后
npm install
就这样...祝你好运!
答案 4 :(得分:0)
就我而言,我不使用代理服务器,但是此错误发生在我身上。
当我尝试在浏览器中访问registry.npmjs.org
时,它没有显示错误
编辑npm配置无济于事
traceroute registry.npmjs.org
解决我的问题
答案 5 :(得分:-2)