I'm trying to make a game in which I need physics and I want to run the logic on the server, but I'm having this problem importing the box2d library into my server, written in NodeJs.
Actually I have the library in a file named "box2d.js"
and it's a module which exports this way
module.exports = Box2D;
And in the server I have tried to require the file and the module, none of them worker
var Box2D = require('./box2d.js');
var Box2D = require('./Box2D');
None of the two options worked, when I run the server It fails and this is the error I get.
E:\project>node index.js
console.js:39
this._stdout.write(util.format.apply(null, arguments) + '\n');
TypeError: Cannot read property 'write' of undefined at Console.log (console.js:39:15) at Server. (E:\Sliball\index.js:327:11) at Server.g (events.js:273:16) at emitNone (events.js:80:13) at Server.emit (events.js:179:7) at emitListeningNT (net.js:1260:10) at _combinedTickCallback (internal/process/next_tick.js:71:11) at process._tickCallback (internal/process/next_tick.js:98:9) at Function.Module.runMain (module.js:449:11) at startup (node.js:146:18)
Any idea about how to fix it? I have already tried 5-6 projects on github, none of them worked.
Thanks!