Node.js + Socket.io + Windows 7 / 8?
我一直在到处寻找,但似乎找不到解决方案。是否可以在 Windows 7 上的 Node.js 上安装 Socket.io?
如果没有,是否有某种替代方案,或者您知道未来有任何 Windows 支持吗?
通常使用 Node.js 包管理器,但是我找不到在 Windows 上安装它的方法。 http://npmjs.org/
我目前正在使用 Node.exe(不是通过 Cygwin 运行它)。
这就是我想象的如果 NPM 工作的话它将如何安装在 Windows 上:
npm install socket.io
Node Package Manager 现在可以在 Windows 7 上工作
只需安装 Node.js 并在 Windows 控制台中输入 npm install socket.io
并查看 C:\Users\[insert用户名]\node_modules
。
I've been searching everywhere, but can't seem to find a solution. Is it possible to install Socket.io on Node.js on Windows 7?
If not, is there some sort of alternative, or do you know of any future Windows support?
Usually the Node.js package manager is used, however I can't find a way of installing that on Windows. http://npmjs.org/
I'm currently using Node.exe (not running it through Cygwin).
This is how I'd imagine it would be installed on Windows, if NPM worked:
npm install socket.io
Node Package Manager now works on Windows 7
Simply install Node.js and type npm install socket.io
into the Windows console and look in C:\Users\[insert username]\node_modules
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(11)
我确认 npm install socket.io 与 Windows 7 上的 Node.js 0.6.10 完美配合(请记住以管理员身份运行 cmd)。
I am confirming that npm install socket.io works perfectly with Node.js 0.6.10 on Windows 7 (remember to run cmd as Administrator).
对于那些在 Windows 上运行 Node.js 和 socket.io 时遇到困难的人...
Google Code 上有一个 nodejs-win 项目。
http ://code.google.com/p/nodejs-win/downloads/detail?name=node_setup_0.5.6.7.exe&can=2&q=
这里是一个视频,展示了使用它的基础知识。
Node.JS & Windows中的Socket.IO聊天系统
For anyone who is having trouble getting Node.js and socket.io working on Windows...
There is the nodejs-win project on Google Code.
http://code.google.com/p/nodejs-win/downloads/detail?name=node_setup_0.5.6.7.exe&can=2&q=
And here is a video that shows the basics of using it.
Node.JS & Socket.IO Chat System in Windows
现在 Node.js 版本 0.6.0 已经可用,并且到目前为止看起来相当稳定,如果您计划在 Windows 上进行开发,我建议使用它。
http://nodejs.org/download/
Now that Node.js version 0.6.0 is available, and it seems pretty stable so far, I'm going to suggest using it if you're planning on developing on Windows.
http://nodejs.org/download/
使用 Linux 盒子或
git clone
socket.io 存储库并从本地路径require
它。您必须将整个 socket.io 库复制到例如
lib/socket.io/
然后
var io = require("./lib/socket.io/index.js
Either use a Linux box or
git clone
the socket.io repository andrequire
it from a local path.You will have to copy the entire socket.io library into, for example,
lib/socket.io/
Then
var io = require("./lib/socket.io/index.js
npm 在 Node.js 上运行。如果您在运行 npm 时遇到问题,那么您在使用 Node.js 时也应该遇到问题。假设您通过 Cygwin 运行 Node.js,那么您应该能够运行
(与 npm install socket.io 相同)
另外。
Npm 只是 Node.js 包管理器。它所提供的一切都是您无法从存储库本身获取的。出于显而易见的原因,使用 npm 更容易。
如果您希望包含 socket.io,则只需在
/lib
目录内或项目所在的任何位置创建一个 node_modules 目录,然后将 socket.io 克隆到其中。https://github.com/LearnBoost/socket.io
编辑
OP表示他是使用节点.exe。截至 2011 年 9 月 1 日,目前无法将 npm 与 node.exe 一起使用。它目前在 node.exe 路线图上,希望很快就能完成,但不是今天。
(如果您想更新,请检查邮件列表)。
npm runs on Node.js. If you are having problems running npm, then you should also be having problems with Node.js. Assuming you are running Node.js through Cygwin, then you should be able to run
(Which is the same as npm install socket.io)
Also.
Npm is just the Node.js package manager. There is nothing that it provides that you can't get from the repositories themselves. It is just, for obvious reasons, a lot easier to use npm.
If you want the socket.io included, then just create a node_modules directory inside of your
/lib
directory or wherever your project is, and then clone the socket.io to it.https://github.com/LearnBoost/socket.io
Edit
The OP indicated that he is using node.exe. There is no way currently as of 1st September 2011 to use npm with node.exe. It is currently on the node.exe roadmap and will hopefully be completed soon, but not as of today.
(Check the mailing list if you want to be updated).
由于 0.6.6 版本(据我记得),Node.js 有一个适用于 Windows 的普通版本,安装后,安装目录中会出现一个 npm.exe 文件,不确定我到底是如何运行它的,也许是这样
node npm install socket.io
。或者也许
npm install socket.io
。如果这些都不起作用,请尝试通过键入完整路径来执行 npm(除非您为该路径添加了系统变量)。郑重声明 - 我已通过 npm 在 Windows 7 上成功安装了 sokcet.io :)Since the 0.6.6 version (as far as I remember) Node.js has a normal version for Windows, and after installing it a npm.exe file appears in the install directory, not sure how exactly I was running it, maybe something like
node npm install socket.io
.Or maybe
npm install socket.io
. If none of these works, try to execute npm by typing full path to it (unless you have added a system variable for the path). For the record - I have successfully installed sokcet.io on Windows 7 via npm :)在为 Windows 构建 NPM 之前,您需要手动下载软件包并在 node.exe 文件夹中创建 node_modules 文件夹结构。关注这篇文章< /a>.
Until NPM is built for Windows you'll need to download the packages manually and create the node_modules folder structure in the node.exe folder. Follow this post.
对我来说,直接从 GitHub 下载模块并将它们放在“node_modules”目录中是可行的。 AFAIK 这就是 npm 所做的。如果将其放在用户目录中,或者放在与 node.exe 相同的目录中,它都可以工作。
遗憾的是,npm 没有 Windows 端口,因为几乎不需要进行任何移植,而且该节点作为独立的可执行文件而不是像 Python 那样的安装程序。
For me, downloading the modules directly from GitHub and putting them in the "node_modules" directory works. AFAIK that's what npm does. It works both if you put it in your user directory, or in the same directory as node.exe.
Too bad there's no Windows port for npm, since there's almost no porting needed to be done, and that node comes as a stand-alone executable instead of an installer, like Python.
我遇到了同样的问题并编辑了 Socket.IO 库以在 Windows 上工作。您可以找到相同的详细信息
I faced the same problem and edited the Socket.IO library to work on windows. Details of the same you can find here.
我在 Windows 7 上使用 Node.js v10.22 时遇到了同样的问题 - 这对我有用:
I had the same problem with Node.js v10.22 on Windows 7 - this worked for me:
使用以下内容在项目目录中创建一个名为
package.json
的文件。然后运行npm安装
Create a file called
package.json
in your project directory with the following.Then run the npm install