node.js npm 安装不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15540338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install not working
提问by Srinivas
I just started learning node.js and i have installed node.js along with npm module manager. I have created a package.json file and from the root directory iam trying to execute npm install command, instead of creating npm_modules folder it throws error like this:
我刚开始学习 node.js,我已经安装了 node.js 和 npm 模块管理器。我创建了一个 package.json 文件,并从根目录 iam 尝试执行 npm install 命令,而不是创建 npm_modules 文件夹,它会引发如下错误:
C:\Users\username\Desktop\nodetest>npm install
npm WARN package.json [email protected] No README.md file found!
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/mongoose
npm ERR! Error: connect ETIMEDOUT
npm ERR! at errnoException (net.js:863:11)
npm ERR! at Object.afterConnect [as oncomplete] (net.js:854:19)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <[email protected]>
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "D:\Program Files\nodejs\\node.exe" "D:\Program Files\no
ejs\node_modules\npm\bin\npm-cli.js" "install"
npm ERR! cwd C:\Users\username\Desktop\nodetest
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
npm ERR! syscall connect
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\username\Desktop\nodetest\npm-debug.log
npm ERR! not ok code 0
Iam using Windows 7 OS.
我正在使用 Windows 7 操作系统。
Any ideas ?
有任何想法吗 ?
Thanks, Srinivas
谢谢,斯里尼瓦斯
回答by khurrum qureshi
This will probably solve your problem:
这可能会解决您的问题:
npm config set proxy proxy-url:port (http:\proxy-name:port)
npm config set https-proxy proxy-url:port
回答by Ramiro Juarez
It was a stuck step on my side,
这是我身边的一个卡住的一步,
the following syntax worked for me:
以下语法对我有用:
npm config set proxyhttp:/myproxyserver:port
npm 配置集代理http:/myproxyserver:port
best regards :)
此致 :)
回答by Gopinath Gunanithi
But still ppl, who ever facing proxy issue in npm install,can try the following method.
但是仍然在 npm install 中遇到代理问题的人,可以尝试以下方法。
Go to C:\Users\YourUserName
Create a file named .npmrc (no need of any prefixname just .npmrc)
Inside that file type the following
转到 C:\Users\YourUserName
创建一个名为 .npmrc 的文件(不需要任何前缀名,只需 .npmrc)
在该文件中键入以下内容
proxy = username:password@ip:port (add http:// before username)
proxy = username:password@ip:port(在用户名前加http://)
That's all.It is perfectly working for me....
这就是全部。它对我来说非常有用......
回答by ZenBalance
You may need to use the windows "run as" command (which is equivalent to the *nix "sudo" command) in order to have the correct privileges on your machine.
您可能需要使用 windows 的“run as”命令(相当于 *nix“sudo”命令)才能在您的机器上拥有正确的权限。
This link should be helpful: https://superuser.com/questions/42537/is-there-any-sudo-command-for-windows
此链接应该会有所帮助:https: //superuser.com/questions/42537/is-there-any-sudo-command-for-windows
回答by Srinivas
finally i came to know that my company laptop has proxy restrictions.Once i got the approval for proxy removal it worked.
最后我才知道我公司的笔记本电脑有代理限制。一旦我获得了代理删除的批准,它就起作用了。
回答by Darren White
The traceroute command will usually tell you wherea connection fails and would have lead you straight to the corporate proxy in this case.
traceroute命令通常会告诉你哪里的连接失败,将有直接导致你在这种情况下,公司的代理。
回答by Bot
Adding to the selected answer
添加到所选答案
a) "npm config set proxy proxy-url:port (http:\proxy-name:port)
a) "npm config set proxy proxy-url:port (http:\proxy-name:port)
b) npm config set https-proxy proxy-url:port"
b) npm config set https-proxy proxy-url:port"
make sure you add "http:\\" to your proxy name, and packages downloaded from npm use ssl so try the second option for sure.
确保将“http:\\”添加到您的代理名称,并且从 npm 下载的软件包使用 ssl,因此请务必尝试第二个选项。
回答by Arthur
- If you are working behind a proxy, configure it:
- 如果您在代理后面工作,请配置它:
npm config set proxy http://login:pass@host:port
npm 配置设置代理http://login:pass@host:port
- Check the value of your proxy configuration:
- 检查代理配置的值:
npm config get http-proxy
npm config 获取 http-proxy
- Try again to get your package...
- 再次尝试获取您的包裹...

