So I went to Git Bash and typed npm install socket.io I found the the directory in my user folder: C:\Users\weka\node_modules… anyway, I dragged the socket.io folder into my project www folder because I am using WAMP server.
So, here’s my server.js for testing:
var app = require('express').createServer();
var io = require('socket.io').listen(app);
io.sockets.on('connection', function (socket) {
console.log('Someone connected!');
socket.on('set nickname' , function (nickname) {
socket.nickname = nickname;
console.log(nickname + ' just connected!');
});
});
app.listen(8080);
and I go into cmd and type node C:\wamp\www\gameTest\server.js
and I get the error that it cannot find the module called express. I thought I downloaded socket.io? I am a newb when it comes to GitHub.. so I probably did it wrong. :\
Help?
UPDATE: I found out I hadn’t installed it. OK, I typed npm install express and I now I have express folder in my node_modules folder.
expressandsocket.ioare different libraries. Justnpm install expressfrom the root of your app.Also, make sure that your
nodedependencies are in a folder callednode_modules– that’s the convention used for module resolution. So, you should have a file structure that looks something like: