npm install ws 不起作用

npm install ws 不起作用

我想在 node.js 中实现一个 websocket 服务器。为此,我想安装“ws”。我已经在我的 ubuntu 系统中安装了 npm 和 node.js。现在我尝试运行命令“sudo npm install ws”,但它不起作用。我正在粘贴我的终端的内容。有人可以帮忙吗?

root@Neeraj:/home/neeraj# npm install ws
npm http GET https://registry.npmjs.org/ws

npm ERR! Error: failed to fetch from registry: ws
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:209:10)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at ClientRequest.onError (/usr/lib/nodejs/request/tunnel.js:164:21)
npm ERR!     at ClientRequest.g (events.js:156:14)
npm ERR! You may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /home/neeraj/npm-debug.log npm
npm ERR! 
npm ERR! System Linux 3.2.0-29-generic-pae
npm ERR! command "node" "/usr/bin/npm" "install" "ws"
npm ERR! cwd /home/neeraj
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: ws
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/neeraj/npm-debug.log
npm not ok
root@Neeraj:/home/neeraj# 

答案1

这篇帖子解决了我的问题,就像使用以下方式建立 npm 注册表一样简单

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

不管怎样,谢谢!

相关内容