Advertisement

Problem requiring Box2d on NodeJs

Started by May 05, 2016 02:15 PM
2 comments, last by Javier Brannigan 8 years, 5 months ago

Hello

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...

module.js:341

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!!!

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
https://nodejs.org/api/modules.html#modules_all_together
My current game project Platform RPG
Advertisement

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
https://nodejs.org/api/modules.html#modules_all_together

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.

Any other idea?

Thanks!

This topic is closed to new replies.

Advertisement