node.js 在 ubuntu 上安装 socket.io

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13826425/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 16:46:23  来源:igfitidea点击:

install socket.io on ubuntu

node.jsubuntusocket.ioreal-time

提问by phpuser12

I'm working on a real time application and I'm using third party to do it. But now I have to use node.js with socket.io instead of third party .

我正在开发一个实时应用程序,我正在使用第三方来完成它。但现在我必须使用 node.js 和 socket.io 而不是第三方。

I installed the node.js (v0.4.12) correctly and I check it using command node -v. but when I was installed the socket.io using npm install socket.iocommand I got this error .

我正确安装了 node.js (v0.4.12) 并使用 command 进行了检查node -v。但是当我使用npm install socket.io命令安装 socket.io 时,我收到了这个错误。

npm ERR! install failed Error: Required package: options(latest) not found. (Found: ["0.0.3"])
npm ERR! install failed (required by: [email protected])
npm ERR! install failed     at /usr/share/npm/lib/build.js:192:19
npm ERR! install failed     at cb (/usr/share/npm/lib/utils/graceful-fs.js:32:9)
npm ERR! Error: Required package: options(latest) not found. (Found: ["0.0.3"])
npm ERR! (required by: [email protected])
npm ERR!     at /usr/share/npm/lib/build.js:192:19
npm ERR!     at cb (/usr/share/npm/lib/utils/graceful-fs.js:32:9)
npm ERR! Report this *entire* log at <http://github.com/isaacs/npm/issues>
npm ERR! or email it to <[email protected]>
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm not ok

How I can solve it?

我该如何解决?

回答by phpuser12

I ran those commands and it worked:

我运行了这些命令并且它起作用了:

  1. sudo npm install -g n
  2. sudo n 0.8.15
  3. sudo npm install socket.io
  1. sudo npm install -g n
  2. sudo n 0.8.15
  3. sudo npm install socket.io

回答by Tejashree

It worked:

有效:

1) sudo npm install -g n
2) sudo n 0.8.15
3) sudo npm install socket.io

1) sudo npm install -gn
2) sudo n 0.8.15
3) sudo npm install socket.io

回答by Loourr

You're trying to install it without a package.jsonfile, and in your solution you installed it globally, which is usually not what you want for socket.io.

您尝试在没有package.json文件的情况下安装它,并且在您的解决方案中全局安装它,这通常不是您想要的 socket.io。

Instead, you should include a package.jsonfile in your working directory and either run:

相反,您应该在工作目录中包含一个package.json文件,然后运行:

> npm install socket.io --save

which will automatically append it to package.json, or your you can physically include it in the dependencies and then just run:

这将自动将其附加到package.json,或者您可以将其物理包含在依赖项中,然后运行:

> npm install

回答by suman1409

In some cases if you are behind a proxy and try to run:

在某些情况下,如果您在代理后面并尝试运行:

sudo npm install socket.io

须藤 npm 安装 socket.io

you may end up in getting error -

你最终可能会得到错误 -

npm ERR! Error: shasum check failed for /tmp/npm-1393245157089/1393245157089-0.6057841922156513/tmp.tgz npm ERR! Expected: 3bab0444e49b55fbbc157424dbd41aa375a51a76 npm ERR! Actual: dae95023b71f7d06533f7c35a7d0c3b0cf729f42

错误!错误:/tmp/npm-1393245157089/1393245157089-0.6057841922156513/tmp.tgz npm ERR 的 shasum 检查失败!预期:3bab0444e49b55fbbc157424dbd41aa375a51a76 npm ERR!实际:dae95023b71f7d06533f7c35a7d0c3b0cf729f42

then run the following

然后运行以下

sudo npm --proxy=http://"your_proxy":"your_port" install socket.io

sudo npm --proxy=http://"your_proxy":"your_port" 安装 socket.io