Closed build1984 closed 6 years ago
Are you able to build and run the example project? https://github.com/bsansouci/reprocessing-example
Hard to know what's going wrong without seeing your setup, maybe you're missing reprocessing in your bsconfig: https://github.com/bsansouci/reprocessing-example/blob/master/bsconfig.json#L4
@Schmavery Hi Avery, thank you for looking into this, I can run the example project just fine, what I'm trying to do is to use something from the Js module, here's my code:
/* seeding to ensure to get random int every time, ref: https://til.hashrocket.com/posts/5mebc3fnbx-seeding-and-generating-random-integers-in-reasonml */
Random.init(int_of_float(Js.Date.now()));
Random.int(10);
When I run npm start
, I got this:
The module or file Js.Date can't be found.
- If it's a third-party dependency:
- Did you list it in bsconfig.json?
- Did you run `bsb` instead of `bsb -make-world`
(latter builds third-parties)?
- Did you include the file's directory in bsconfig.json?
One thing to note is that if you're using any Js.*
functions, you won't be able to build your project to native/bytecode (since those functions are just bindings to JS!). It should still work fine if you're building to the js backend (with something like bsb -make-world -backend js
, the reprocessing-example has a npm run build:web
target for this).
Not sure how representative your example is, but Reprocessing should already be seeding the Random module at the beginning of your program in case that helps. You could also use something like this: http://caml.inria.fr/pub/docs/manual-ocaml/libref/Unix.html#VALtime
@Schmavery Hi Avery, thank you so much for helping me understand why Js module is not available in the native environment, and also pointing me to the unix module!
I'm fairly new to to the ReasonML ecosystem, I try to and a
Js.log()
statement in my game for debugging purpose (to log out the state, complex structure, print_endline won't do it), but I gotThe module or file Reprocessing can't be found.
error in my console when Inpm start
. How do I include Js module into my reprocessing project?