{"id":48922,"library":"pkg-fetch","title":"pkg-fetch","description":"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.","status":"active","version":"3.5.2","language":"javascript","source_language":"en","source_url":"https://github.com/vercel/pkg-fetch","tags":["javascript","typescript"],"install":[{"cmd":"npm install pkg-fetch","lang":"bash","label":"npm"},{"cmd":"yarn add pkg-fetch","lang":"bash","label":"yarn"},{"cmd":"pnpm add pkg-fetch","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used to download prebuilt Node binaries from GitHub releases.","package":"node-fetch","optional":false},{"reason":"Used to parse and compare Node.js version strings.","package":"semver","optional":false}],"imports":[{"note":"ESM-only package; use dynamic import in CommonJS.","wrong":"const fetch = require('pkg-fetch')","symbol":"pkg-fetch","correct":"import fetch from 'pkg-fetch'"},{"note":"Named export for fetching a specific Node binary.","wrong":"const fetchBin = require('pkg-fetch').fetchBin","symbol":"fetchBin","correct":"import { fetchBin } from 'pkg-fetch'"},{"note":"Type only; use type import to avoid runtime inclusion.","wrong":"import { NodeBinaryOptions } from 'pkg-fetch'","symbol":"NodeBinaryOptions","correct":"import type { NodeBinaryOptions } from 'pkg-fetch'"}],"quickstart":{"code":"import fetch from 'pkg-fetch';\n\nasync function main() {\n  try {\n    const binPath = await fetch({\n      nodeRange: 'node18',\n      platform: 'linux',\n      arch: 'x64'\n    });\n    console.log(`Binary downloaded to: ${binPath}`);\n  } catch (err) {\n    console.error('Failed to fetch binary:', err);\n  }\n}\n\nmain();","lang":"typescript","description":"Demonstrates fetching a Node 18 binary for Linux x64, using the default export with async/await."},"warnings":[{"fix":"Upgrade to Node.js 14+ for continued support.","message":"Node.js 8, 10, and 12 binaries are EOL and may be removed in the next major release of pkg-fetch.","severity":"breaking","affected_versions":">=3.0"},{"fix":"Ensure your macOS version is 11.0 or later, and that binaries are signed (Apple's Gatekeeper).","message":"macOS ARM64 binaries require mandatory code signing by Apple (macOS 11.0+).","severity":"gotcha","affected_versions":">=3.0"},{"fix":"Do not rely on linuxstatic armv7 for production; use linux armv7 if available.","message":"linuxstatic armv7 builds are provided on a best-effort basis and are not semver-protected.","severity":"gotcha","affected_versions":">=3.0"}],"env_vars":null,"search_vec":"'10':43 '12':44 '14':45 '16':46 '18':47 '8':42 'across':48 'action':87 'align':75 'alpin':50 'architectur':56 'arm64':58 'armv7':59 'avail':82 'binari':16,34,81 'broad':97 'build':13,88 'cadenc':74 'chain':94 'critic':68 'depend':69 'differenti':84 'execut':24 'fetch':3,6,11 'generat':23 'github':86 'hardcod':89 'hash':91 'javascript':100 'key':83 'linux':51 'linuxstat':52 'maco':53 'maintain':62 'node':40 'node.js':15,80 'packag':26 'patch':14 'pkg':2,5,20,71,77 'pkg-fetch':1,4 'platform':49 'platform/architecture':98 'prebuilt':33 'provid':32 'rang':38 'releas':73 'secur':95 'ship':28 'sourc':90 'suppli':93 'support':99 'tool':21 'transpar':85 'type':30 'typescript':29,101 'updat':78 'use':17 'user':72 'util':9 'v3.5.2':27 'vercel':64 'version':41 'wide':37 'win':54 'x64':57","created_at":"2026-06-07T16:59:09.463945+00:00","updated_at":"2026-06-07T16:59:09.463945+00:00","problems":[{"fix":"Set the PKG_CACHE_PATH environment variable to a writable directory or run with sudo.","cause":"pkg-fetch tries to write to a cache directory without appropriate permissions.","error":"Error: EACCES: permission denied, mkdir '/root/.pkg-cache'"},{"fix":"Check internet connection, firewall, or use a proxy by setting the HTTPS_PROXY environment variable.","cause":"Network connectivity issue or GitHub being unreachable.","error":"FetchError: request to https://github.com/vercel/pkg-fetch/releases/download/v3.5.2/fetched-v18.0.0-linux-x64 failed, reason: read ECONNRESET"},{"fix":"Use a different Node version that supports win32-arm64 (e.g., Node 14, 16, or 18) or switch architecture.","cause":"The requested Node version does not have a prebuilt binary for Windows ARM64.","error":"Error: Unsupported platform: win32-arm64"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/vercel/pkg-fetch#readme","github":"https://github.com/vercel/pkg-fetch","docs":null,"changelog":null,"pypi":null,"npm":"pkg-fetch","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}