node -> pkg -> bootstrap -> run
Utility to package a Node.js app into a single executable file requiring zero dependencies.
Package node.exe
, node_modules
folder, and app bundle.js
into a single node executable created with pkg. Running the executable bootstraps node by extracting the embedded node app and running it in a temporary folder.
- Bundle node app into a single js file with as many node modules dependencies as possible.
- Using whatever bundler
- Excluding node dependencies that cannot be bundled. For using workers, external utils, etc.
- Create a separate
node_modules
folder of the node dependencies that could not be bundled- Running
npm install
- Cleaning
node_modules
folder from symlinks and non-prod files.
- Running
- Archive the
node_modules
folder - Archive selected
node.exe
executable - Create a single executable file using pkg that executes
bootstrap.js
and incudes node_modules archive, node.exe archive, and app bundle file. - Running the node-executable created by pkg
- Create a temp folder for the node app
- Extract node.exe
- Extract node_modules
- Copy app bundle
- Run node app with the extracted node and app bundle
tmpfolder/node.exe tmpfolder/bundle.js