2

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!

coNNecTT
  • 85
  • 2
  • 7
  • 1
    If you have a single error occurring repeatedly, it isn't random. What's on line 16 of **main.js**? and line 20 of **tcp_server.js**? – Kevin B Jun 05 '15 at 21:50
  • 1
    It's "console.log("any string");. And yeah, you're right, I mean that it seems random to me since Box2D shouldn't mess up.something like "console.log()". And on line 20 it's 'self.emit('listen', { ip: address.address, port: address.port });' – coNNecTT Jun 05 '15 at 21:53
  • how is the application being started? – Kevin B Jun 05 '15 at 21:54
  • Through a .bat file "node main.js" (there are 3 more lines but I don't think they matter). – coNNecTT Jun 05 '15 at 21:56
  • 1
    Found some information regarding this exact same error: GrymmyD TETR • 2 years ago FYI - The following line (26 of Box2D.js) is the issue: Object.defineProperty = function(obj, p, cfg) { The issue is that console.js relies on the defineProperty method for setting _stdout and _stderr... I've commented out that statement and it runs in Node... I'm early along in development, so I don't know if there are any side effects, but my guess is that that code was in there for debugging purposes...? – coNNecTT Jun 05 '15 at 22:09

0 Answers0