What is pkg?
pkg is a command-line tool that packages your Node.js project into a single self-contained executable. The resulting binary runs on devices that don't have Node.js installed, ship no node_modules, and boot like any other native CLI tool.
Use cases
- Make a commercial version of your application without sources
- Make a demo, evaluation, or trial version of your app without sources
- Instantly make executables for other platforms (cross-compilation)
- Make a self-extracting archive or installer
- Skip installing Node.js and npm on the deployment target
- Deploy a single file instead of hundreds of
npm installartifacts - Put your assets inside the executable to make it even more portable
- Test your app against a new Node.js version without installing it
Two packaging modes
pkg builds executables in either Standard mode (patched Node.js, bytecode, compression) or Enhanced SEA mode (stock Node.js via the Single Executable Applications API). See SEA vs Standard to pick.
How it works
The walker follows require / import from your entry file, pulls in every dependency, optionally compiles JavaScript to V8 bytecode (Standard) or keeps source (SEA), and injects the whole bundle into a Node.js binary.
Want the full story? See Architecture.
Next steps
- Getting started — install and build your first binary
- Targets — cross-compile for other platforms
- Configuration — scripts, assets, and the
pkgproperty inpackage.json - SEA vs Standard — which mode to pick
- Recipes — copy-paste solutions
- Migration from vercel/pkg
