box2d.js icon indicating copy to clipboard operation
box2d.js copied to clipboard

Errors in Node.js environment

Open schulzch opened this issue 13 years ago • 1 comments

There are some issues with using box2d.js in a Node.js environment:

  • it's not exported as Node.js module
  • Mocha detects Error: global leak detected: Module

The fixes are easy, but I have no idea where to put them:

  • replace Module; with var Module; somewhere
  • add module.exports = Module; at the end of the file

Cheers, Chris

schulzch avatar Nov 02 '12 02:11 schulzch

I fiddled around a bit and came up with the following solution:

/*
 * https://github.com/kripken/box2d.js
 *
 * box2d.js is zlib licensed, just like Box2D.
 */
// ... COMPILED ONE LINER GOES HERE ...
module.exports = this.Box2D;

Edit: Adding --globals Module to mocha's command line seems cleaner for now.

schulzch avatar Nov 02 '12 12:11 schulzch