Package Node.js projects into standalone executables that run without Node.js installed.
pkg is a deprecated command-line tool that packages Node.js applications into standalone executables, allowing them to run on systems without Node.js installed. It bundles the application source code, dependencies, and assets into a single binary, simplifying distribution and deployment. The tool supports cross-compilation for multiple platforms and architectures from a single build environment.
Node.js developers who need to distribute applications as portable binaries, particularly for commercial software, demos, or environments where installing Node.js is impractical.
Developers choose pkg for its ability to create truly standalone executables with no external dependencies, cross-platform support, and integration with native modules. Its bytecode compilation option provides basic source code obfuscation.
Package your Node.js project into an executable
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Generates executables for Linux, macOS, and Windows from a single machine, as shown in the README with examples like 'pkg -t node16-linux,node18-win index.js'.
Packaged applications run without installing Node.js or npm modules, enabling deployment on machines without a Node.js environment.
Bundles JavaScript files, native addons, and static assets directly into the executable, simplifying distribution and reducing external file dependencies.
Compiles source code to V8 bytecode by default, adding a layer of source code protection and potential performance gains, though with reproducibility trade-offs.
The project is archived with no further updates, meaning no bug fixes, security patches, or compatibility with newer Node.js versions beyond the last release.
Requires manual specification in package.json for non-literal require calls or dynamic asset paths, which can be error-prone and increase setup complexity.
Native modules need compatibility with target Node.js versions and create temporary files on disk, adding overhead and potential cross-platform issues.
Issues like mandatory code signing on macOS-arm64 and the need for QEMU emulation on Linux for cross-architecture compilation make usage more involved.