Recently there is a newer version of node.js which supports npm for windows.
I followed the instructions here And i've installed socket.io successfully on windows through npm (though some failed, like JSDOM)
However when I require the module the followings fails:
var io = require("socket.io").listen(1234);
and also
var io = require("./lib/node_modules/socket.io/index.js").listen(1234);
Which shows "Cannot find module "socket.io"
However this works:
var io = require('/NodeDev/lib/node_modules/socket.io/index.js').listen(1234);
Here is where my stuff are placed:
folder socket.io : in D:\NodeDev\lib\node_modules\
node.exe : in D:\NodeDev\bin\
my script : in D:\NodeDev\TestProject\
I had a similar problem when dealing with generally available packages in Windows. It worked when I installed the packages directly into my project:
cd myProject
npm install socket.io
It then gets installed into the myProject/node_modules folder. At that time, doing a require('socket.io') works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With