Node.js安装socket.io时出现npm错误

3

我是一个新的node.js开发者。我正在尝试编写一个简单的聊天项目。因此,我想通过NPM安装socket.io,但是我遇到了这个错误。

我使用的是Ubuntu 12.04。

ubuntu@Ubuntu-1210:~/Masaüstü/blog$ npm install socket.io
npm http GET https://registry.npmjs.org/socket.io

npm ERR! Error: failed to fetch from registry: socket.io
npm ERR!     at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
npm ERR!     at cb (/usr/share/npm/lib/utils/npm-registry-client/request.js:31:9)
npm ERR!     at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
npm ERR!     at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
npm ERR!     at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
npm ERR!     at Request.emit (events.js:88:20)
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at HTTPParser.onIncoming (http.js:1261:11)
npm ERR!     at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR! You may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /home/ubuntu/Masaüstü/blog/npm-debug.log npm
npm ERR! 
npm ERR! System Linux 3.8.0-35-generic
npm ERR! command "node" "/usr/bin/npm" "install" "socket.io"
npm ERR! cwd /home/ubuntu/Masaüstü/blog
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: socket.io
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/ubuntu/Masaüstü/blog/npm-debug.log
npm not ok

非常抱歉,我的英语不太好。感谢您。


2
你尝试过访问 https://dev59.com/kGcs5IYBdhLWcg3wXSyU 吗? - bbill
1
谢谢,问题已经解决了 :) - Olkunmustafa
2个回答

14

像我在上面评论中发布的链接中的答案一样,我建议首先运行

npm config set registry https://registry.npmjs.org/

你也可以使用不同的镜像源,比如Nodejitsu托管的镜像源:npm config set registry https://registry.nodejitsu.com/ - 3rdEden
1
这是不安全的,因为您没有使用https。 - AzizAhmad

2

建议使用sudo。

sudo npm install socket.io

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接