When I saw that nim could compile to javascript, I thought "Cool", but it isn't that easy. I still don't know how it works.
The Documentation doesn't seem to explain it, and the samples that I could find talk about defining functions in other files and stuff like that. But how does it work? It doesn't just write js code with nim, but I don't know how else it would create javascript. And how does nim handle all the available javascript modules!
To compile Nim to JS, run nim js myfile.nim, simple as that.
To use modules from npm, use jsffi module (https://nim-lang.org/docs/jsffi.html) and Webpack with Nim loader (https://github.com/bmollot/nim-loade).
I tried it, works really well.