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

后端 未结 11 1815
迷失自我
迷失自我 2021-02-07 05:29

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 alternati

相关标签:
11条回答
  • 2021-02-07 05:42

    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

    0 讨论(0)
  • 2021-02-07 05:44

    I faced the same problem and edited the Socket.IO library to work on windows. Details of the same you can find here.

    0 讨论(0)
  • 2021-02-07 05:48

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

    0 讨论(0)
  • 2021-02-07 05:50

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

    0 讨论(0)
  • 2021-02-07 05:50

    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.

    0 讨论(0)
  • 2021-02-07 05:56

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

    0 讨论(0)
提交回复
热议问题