How to compile node.js files into binary executables
pkgfrom npm with this command (don’t do it from the editor)
npm i pkg -D -S
/app/node_modules/.bin/pkg -vto make sure it was installed correctly. It should return with a number (e.g
Compile the files! Navigate to the
cd /tmp) and run this command:
Tips and tricks
- The compiler will compilie for Windows, Mac, and Linix based systems. It cn take up to 172mb (even for the ~hello-express app!). So, try to specify one platform at a time by adding
Platforms: freebsd, linux, alpine, macos, win
Archs: x64, x86, armv6, armv7
Node Versions: You pick!
- To run your binary in Linux, type
./(Name Of Binary)
- To run your binary in Windows, type the name of your binary.