简体   繁体   English

NPM安装不起作用

[英]npm install not working

I just started learning node.js and i have installed node.js along with npm module manager. 我刚刚开始学习node.js,并且已经安装了node.js和npm模块管理器。 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: 我创建了一个package.json文件,并从根目录iam尝试执行npm install命令,而不是创建npm_modules文件夹,它引发了如下错误:

C:\Users\username\Desktop\nodetest>npm install
npm WARN package.json backbone-library@0.0.1 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!     <npm-@googlegroups.com>


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. Iam使用Windows 7 OS。

Any ideas ? 有任何想法吗 ?

Thanks, Srinivas 谢谢,斯里尼瓦斯

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

It was a stuck step on my side, 这是我坚持的一步,

the following syntax worked for me: 以下语法对我有用:

npm config set proxy http:/myproxyserver:port npm config 设置代理 http:/ myproxyserver:port

best regards :) 最好的祝福 :)

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“运行方式”命令(等效于* 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

终于我知道我公司的笔记本电脑有代理限制。一旦获得代理删除的批准,它就可以工作了。

But still ppl, who ever facing proxy issue in npm install,can try the following method. 但是仍然在npm install中遇到代理问题的ppl可以尝试以下方法。

Go to C:\\Users\\YourUserName 转到C:\\ Users \\ YourUserName
Create a file named .npmrc (no need of any prefixname just .npmrc) 创建一个名为.npmrc的文件(不需要任何前缀名,只需.npmrc)
Inside that file type the following 在该文件内键入以下内容

proxy = username:password@ip:port (add http:// before username) proxy =用户名:password @ ip:port(在用户名前添加http://)

That's all.It is perfectly working for me.... 仅此而已。

traceroute命令通常会告诉你在哪里连接失败,将会导致你直在这种情况下,公司的代理。

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设置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,因此请确保尝试第二个选项。

  1. If you are working behind a proxy, configure it: 如果您正在使用代理,请对其进行配置:

npm config set proxy http://login:pass@host:port npm配置设置代理http:// login:pass @ host:port

  1. Check the value of your proxy configuration: 检查您的代理配置的值:

npm config get http-proxy npm config获取http-proxy

  1. Try again to get your package... 再试一次以获取您的包裹...

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

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