2 ms·
pkg "compiles" your app into a binary with a virtual file system inside the app. If you do a "require", the runtime rewrites that call and attempts to load the
by xrd 5y ago
pkg "compiles" your app into a binary with a virtual file system inside the app. If you do a "require", the runtime rewrites that call and attempts to load the files from inside the sandbox virtual file system.
You can even provide assets (like say a JS app and associated HTML, CSS) that are stored inside the app. You can then build a full app as a single binary with no extra dependencies or files. There are a few gotchas like when you need native library support in your app (if you are using a sqlite driver) and then you need to ship a .node file with your app. But, generally, it is a great solution once you get the hang of it.
You compile against a specific version of node, and that runtime is included in your binary. You don't need the client to install node or choose a version, you lock that down when you build your app.
I've experimented with a lot of different nodejs packaging tools, but pkg seems to work the best with the fewest surprises.