Node.js + Socket.io + Windows 7 / 8?

2020-05-31 22:41发布

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.

11条回答
兄弟一词,经得起流年.
2楼-- · 2020-05-31 22:46

I had the same problem with Node.js v10.22 on Windows 7 - this worked for me:

npm install socket.io@0.8.4
查看更多
祖国的老花朵
3楼-- · 2020-05-31 22:46

Create a file called package.json in your project directory with the following.

{
     "name": "project name",
     "description": "project description,
     "version": "0.0.1",
     "dependencies": {
        "express": "2.4.6",
        "socket.io": "version"
     }
}

Then run the npm install

查看更多
太酷不给撩
4楼-- · 2020-05-31 22:49

Either use a Linux box or git clone the socket.io repository and require 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

查看更多
甜甜的少女心
5楼-- · 2020-05-31 22:54

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 :)

查看更多
倾城 Initia
6楼-- · 2020-05-31 22:58

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).

查看更多
ゆ 、 Hurt°
7楼-- · 2020-05-31 23:03

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

查看更多
登录 后发表回答