npm安装不工作
我刚开始学习node.js,我已经安装了node.js和npm模块pipe理器。 我已经创build了一个package.json文件,并从根目录iam试图执行npm install命令,而不是创buildnpm_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使用Windows 7操作系统。
有任何想法吗 ?
谢谢,Srinivas
这将解决您的问题
npm config set proxy proxy-url:port(http:\ proxy-name:port)
npm config set https-proxy proxy-url:port
这是我身边卡住的一步,
下面的语法为我工作:
npm config set proxy http:/ myproxyserver:port
最好的祝福 :)
您可能需要使用Windows“run as”命令(相当于* nix“sudo”命令)才能在您的计算机上拥有正确的权限。
这个链接应该是有帮助的: https : //superuser.com/questions/42537/is-there-any-sudo-command-for-windows
最后我才知道我公司的笔记本电脑有代理限制。一旦我得到了代理移除的批准,它的工作。
但是,仍然是ppl,在npm install中遇到代理问题,可以尝试下面的方法。
转到C:\ Users \ YourUserName
创build一个名为.npmrc的文件(不需要任何前缀名只是.npmrc)
在该文件中input以下内容
代理=用户名:密码@ ip:端口(添加http://之前的用户名)
这就是全部,它完全为我工作….
traceroute命令通常会告诉你连接失败的地方,在这种情况下会导致你直接进入公司代理。
添加到选定的答案
a)“npm config set proxy proxy-url:port(http:\ proxy-name:port)
b)npm config set https-proxy proxy-url:port“
确保你添加“http:\\”到你的代理名称,并且从npm下载的包使用ssl,所以尝试第二个选项。
- 如果您正在使用代理,请对其进行configuration:
npm config set proxy http:// login:pass @ host:port
- 检查您的代理configuration的值:
npmconfiguration得到http代理
- 再试一次,以获得您的软件包…