-->

Node.js Box2dWeb error caused by require()

2019-07-08 08:01发布

问题:

I'm trying to make a server using Node.js and Box2dWeb engine. But trying to "import" the "box2d.js" throws me a random error which doesn't seem to be related with what I'm doing. Here's the code that's causing the error:

var Box2D = require('./box2d.js');

Here's the error:

console.js:55
this._stdout.write(util.format.apply(this, arguments) + '\n');
          ^
TypeError: Cannot read property 'write' of undefined
 at Console.log (console.js:55:15)
at TCPServer.<anonymous> (C:\Users\conne_000\Documents\ntm2\NTM2Server2\main
.js:16:10)
at TCPServer.emit (events.js:129:20)
at Server.<anonymous> (C:\Users\conne_000\Documents\ntm2\NTM2Server2\classes\servers\tcp_server.js:20:8)
at Server.emit (events.js:104:17)
at net.js:1171:12
at process._tickCallback (node.js:355:11)
at Function.Module.runMain (module.js:503:11)
at startup (node.js:129:16)
at node.js:814:3
Press any key to continue . . .

I have no idea on what to do about this. Any help is very much appreciated!