Try specifying the Module.locateFile() callback: http://kripken.github.io/emscripten-site/docs/api_reference/module.html#Module.locateFile
You can use that to tell the loader the path of where to look for any files, not just the .js.mem file. (Btw, with .wasm the memory init file will be gone, which is pretty nice) 2017-02-11 21:10 GMT+02:00 Tomas Reimers <[email protected]>: > Hi all, > > I think I'm overlooking something fundamental, so would appreciate any > help / tips! > > When you compile any $FILE with optimizations it produces a separate > $FILE.js.mem file for memory initialization. When you then try to open > $FILE from node, it looks in the cwd for $FILE.js.mem. This creates a > problem when you're trying to run the file from any directory besides its > own. > > I found this old post <https://github.com/kripken/emscripten/issues/2537> from > 2014 detailing the problem, and then this function in Module > <https://kripken.github.io/emscripten-site/docs/api_reference/module.html#Module.locateFile> > that > would allow you to define a custom search path for .js.mem; however that > seems inconvenient because (as best as I can tell) the emscripten Module in > node can't be defined before you try to load the .js.mem... > > So, without simply setting --memory-init-file 0 how can you require a > compiled asm module from a different directory? Is there a way to easily > define Module before you require() the emscripten file? Right now I'm doing > something akin to: > > let cwd = process.cwd(); > process.chdir(__dirname + '/../other/path/'); > const my_lib = require('../other/path/my_lib.js'); > process.chdir(cwd); > > But this seems hackish... > > Thanks, > Tomas > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
