Tool:pkg (Node.js packager)
| Developer | Vercel |
|---|---|
| License | MIT |
| Website | https://github.com/vercel/pkg |
| On this wiki | Facts · Code · Notes · Topics |
Deprecated Vercel packager that bakes a virtual file system of the app (served under /snapshot) into a patched Node.js binary by overwriting padded placeholder strings with the payload and prelude positions and sizes.
Identification
- Strings in the executable:
/snapshot/path prefix (on WindowsC:\snapshot\), the environment variablePKG_EXECPATHand the valuePKG_INVOKE_NODEJS. Source files appear under paths like/snapshot/<app>/node_modules/...in stack traces. - The packaged files are appended after the patched Node.js binary as a payload; the prelude (bootstrap.js from the pkg repository) is a JavaScript text appended after it. The binary template contains placeholders that pkg overwrites in place:
// PAYLOAD_POSITION //,// PAYLOAD_SIZE //,// PRELUDE_POSITION //,// PRELUDE_SIZE //(padded with spaces) and a// BAKERYx20 string (NUL-padded) for build options. In a finished executable these hold decimal numbers instead of the markers, so search for those strings in the template, and for the numbers in a build (Fact:pkg (Node.js packager)/identification/Placeholders).
Content
The payload is a concatenation of file records addressed by PAYLOAD_POSITION + offset; the prelude bootstrap receives a VIRTUAL_FILESYSTEM table (per path, record kinds STORE_BLOB 0, STORE_CONTENT 1, STORE_LINKS 2, STORE_STAT 3 each with offset and size), a DICT of shortened path segments, DOCOMPRESS (0 none; Brotli or GZip otherwise), SYMLINKS and DEFAULT_ENTRYPOINT. JavaScript sources are stored as source (default) or, with --no-bytecode absent, as V8 bytecode with a fabricated source stub: the bytecode form depends on the exact V8 version of the host. Unverified: record framing of the payload; read lib/producer.ts and prelude/bootstrap.js for the exact scheme.
Status
The repository is archived (last release 5.8.1); forks such as yao-pkg continue it. See Format:Node.js single executable application for the official replacement and Tool:nexe.
Code & repositories
- https://github.com/vercel/pkg @
9066ceeb391d9c7ba6aba650109c2fa3f8e088eb· license: MIT
vercel/pkg (MIT, archived): producer.ts writes the payload and placeholders; prelude/bootstrap.js is the runtime virtual file system.
Tested on: source read, not run: Read the source at this commit; not run. · checked 2026-10-18; archived; last activity 2024-01-03
Evidence & references
- vercel/pkg commit 9066ceeb391d9c7ba6aba650109c2fa3f8e088eb (MIT):
lib/producer.tslines 25-140 (placeholders),lib/common.tslines 5-8 (STORE_*),prelude/bootstrap.jslines 8-90, 440-470 (globals, PAYLOAD_POSITION use, PKG_EXECPATH).