可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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
.
回答1:
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).
回答2:
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
回答3:
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/
回答4:
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:
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
node npm install socket.io
(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).
回答6:
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 :)
回答7:
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.
回答8:
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.
回答9:
I faced the same problem and edited the Socket.IO library to work on windows. Details of the same you can find here.
回答10:
I had the same problem with Node.js v10.22 on Windows 7 - this worked for me:
npm install socket.io@0.8.4
回答11:
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