Skip to content

pkg

Packages a Node.js project into a single executable that runs without Node.js installed. Archived.

Stars
24.3k
Forks
1.1k
Licence
MIT
Language
JavaScript
Last update
2.8 years ago
Type
Dev tool

This repository is archived and no longer maintained.

What it is

pkg is a command-line tool that bundles a Node.js project, along with its dependencies and any extra files you specify, into one executable file. The result can run on machines that do not have Node.js or npm installed. The README says the project is deprecated: 5.8.1 is the last release, the repository is archived, and forks exist with additional features.

  • Turn a Node.js CLI into a single executable for Linux, macOS, and Windows with pkg index.js
  • Build for a specific target such as node16-win-arm64 using the -t option
  • Bundle non-JavaScript assets like views or images into the executable using the pkg section in package.json
  • Bake Node.js or V8 runtime options such as expose-gc into the executable with --options

Great for

  • Developers who want to ship a Node.js command-line tool as a single file to users without Node.js
  • Teams packaging an internal tool for machines where installing Node.js is not practical
  • People who need a demo or trial build of a Node.js app without shipping source files

Not ideal for

  • New projects: the README says pkg is deprecated and archived, so it will not receive updates; look at the forks or Node.js 21+ single executable applications instead
  • Anyone needing a supported, maintained build tool, since the last push was January 2024
  • Users who need binaries for every platform without extra setup, since the README says cross-architecture builds may need QEMU, Rosetta 2, or ldid

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js

    Install pkg globally with npm

    npm install -g pkg
  2. 2

    Run it

    • Run pkg --help to see the available options
    • Run pkg index.js, replacing index.js with your entry file
    • Run the generated executable on a machine without Node.js to confirm it works
  3. 3

    Get the most out of it

    • Use the pkg section of package.json to list scripts, assets, and targets
    • Use --targets to build for several platforms in one run, for example -t node16-linux,node18-linux,node16-win
    • Use --compress GZip or Brotli to reduce the size of packaged data
    • Use --debug to log the packaging process when a file is missing from the output

Downloads

Strengths

  • Produces a single file, so deployment avoids installing hundreds of npm packages
  • Can cross-compile to several platforms and Node.js versions from one host
  • Supports bundling assets and optional Brotli or GZip compression of packaged data

Trade-offs

  • Archived and deprecated, with the final release 5.8.1 and no new development
  • Cross-architecture builds may require extra tools such as QEMU, Rosetta 2, or ldid, and macOS binaries must be signed
  • Dynamic require calls and non-JavaScript files are not detected automatically and must be listed manually

How it compares

ProjectStarsTypeLevelUpdatedBest for
pkg (this)24.3kDev toolintermediate2.8 years agoDevelopers who want to ship a Node.js command-line tool as a single file to users without Node.js
nexe13.6kCLIintermediate8 months agoDevelopers who want to hand a Node.js program to someone without asking them to install Node.js
webpack66kDev toolintermediate4 days agoFrontend developers building single-page or multi-page web apps
babel44.1kDev toolintermediate4 days agoWeb developers who want to use recent JavaScript syntax while still supporting older browsers
parcel44kDev toolbeginner4 days agoWeb developers who want a bundler that works without a config file
esbuild40.1kDev toolintermediate3 months agoDevelopers who want fast builds for JavaScript, TypeScript, or CSS projects

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.