Jump to content
  • Advertisement
Sign in to follow this  
Javier Brannigan

Problem requiring Box2d on NodeJs

This topic is 948 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



Iam having problems to use Box2d on the server... The fact is that when I require the module or box2d file, the server throws a fatal Error...


I have the classic library in a file named "box2d.js" which is exported in the end


module.exports = Box2D


And in my server I have tried to call it through two ways... Calling the module and requiring the file


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

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

But none of these two options worked, when I run the server, I get this...




    throw err;
Error: Cannot find module './box2d.'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (E:\project\index.js:61:13)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)


I have tried to run it in 4 o 5 projects on github, in all of them the same error... I have already tried with different files too, but the projects don't work neither... I'm using Nodejs 5.1... Any idea about what's happening or how to fix it? 


Thanks very much!!!

Share this post

Link to post
Share on other sites

what is the file structure look like? is box2d.js in the same directory as the file importing it?
Take a look at the section titled "All Together..." it describes how the require looks for files

I'm sorry, but being honest... I didn't understand anything of the pseudo code


I have placed the file in different  directories, actually it's in one called "server"... But I don't think there problem is there, because when I run projects downloaded from github, they don't work neither, so maybe the problem is at my nodeJs... I don't know.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!