Registry / devops / pkg-fetch

pkg-fetch

JSON →
library3.5.2jsnpmunverified

pkg-fetch is a utility to fetch or build patched Node.js binaries used by the pkg tool to generate executables. The package v3.5.2 ships TypeScript types and provides prebuilt binaries for a wide range of Node versions (8, 10, 12, 14, 16, 18) across platforms (alpine, linux, linuxstatic, macos, win) and architectures (x64, arm64, armv7). It is maintained by Vercel and is a critical dependency for pkg users. Release cadence aligns with pkg updates and Node.js binary availability. Key differentiators: transparent GitHub Actions builds, hardcoded source hashes for supply chain security, and broad platform/architecture support.

npm install pkg-fetch
INSTALL
IMPORT
SIG · PKG-FETCH
P
pkg-fetch
devopsjavascriptv3.5.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pkg-fetch
import fetch from 'pkg-fetch'
const fetch = require('pkg-fetch')
ESM-only package; use dynamic import in CommonJS.
fetchBin
import { fetchBin } from 'pkg-fetch'
const fetchBin = require('pkg-fetch').fetchBin
Named export for fetching a specific Node binary.
NodeBinaryOptions
import type { NodeBinaryOptions } from 'pkg-fetch'
import { NodeBinaryOptions } from 'pkg-fetch'
Type only; use type import to avoid runtime inclusion.

Demonstrates fetching a Node 18 binary for Linux x64, using the default export with async/await.

import fetch from 'pkg-fetch'; async function main() { try { const binPath = await fetch({ nodeRange: 'node18', platform: 'linux', arch: 'x64' }); console.log(`Binary downloaded to: ${binPath}`); } catch (err) { console.error('Failed to fetch binary:', err); } } main();
Debug
Known issues
breakingNode.js 8, 10, and 12 binaries are EOL and may be removed in the next major release of pkg-fetch.
fix
Upgrade to Node.js 14+ for continued support.
affects: >=3.0
gotchamacOS ARM64 binaries require mandatory code signing by Apple (macOS 11.0+).
fix
Ensure your macOS version is 11.0 or later, and that binaries are signed (Apple's Gatekeeper).
affects: >=3.0
gotchalinuxstatic armv7 builds are provided on a best-effort basis and are not semver-protected.
fix
Do not rely on linuxstatic armv7 for production; use linux armv7 if available.
affects: >=3.0
Errors
Common errors & fixes
Error: EACCES: permission denied, mkdir '/root/.pkg-cache'
pkg-fetch tries to write to a cache directory without appropriate permissions.
fix
Set the PKG_CACHE_PATH environment variable to a writable directory or run with sudo.
FetchError: request to https://github.com/vercel/pkg-fetch/releases/download/v3.5.2/fetched-v18.0.0-linux-x64 failed, reason: read ECONNRESET
Network connectivity issue or GitHub being unreachable.
fix
Check internet connection, firewall, or use a proxy by setting the HTTPS_PROXY environment variable.
Error: Unsupported platform: win32-arm64
The requested Node version does not have a prebuilt binary for Windows ARM64.
fix
Use a different Node version that supports win32-arm64 (e.g., Node 14, 16, or 18) or switch architecture.
Upgrade
Version history
3.5.2latest on npm
Audit
Dependencies
node-fetchrequiredUsed to download prebuilt Node binaries from GitHub releases.
semverrequiredUsed to parse and compare Node.js version strings.
Agent activity
7 hits · last 30 days
node
6
Resources
pkg-fetch — npm install pkg-fetch · libregistry