Registry / devops / fetch-executable

fetch-executable

JSON →
library0.17.1jsnpmunverified

fetch-executable (v0.17.1) is a Node.js library for downloading and caching exact versions of CLI executables on a per-project basis. It checks if the correct version is already present locally before downloading, saving bandwidth and ensuring reproducibility. Key differentiators: supports version checks via --version, hash verification, tar extraction, and includes built-in shortcuts for 15 popular tools (kubectl, helm, terraform, etc.). Released under MIT, actively maintained with regular updates.

npm install fetch-executable
INSTALL
IMPORT
SIG · FETCH-EXECUTABLE
F
fetch-executable
devopsjavascriptv0.17.1
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.

fetchExecutable
import { fetchExecutable } from 'fetch-executable'
const { fetchExecutable } = require('fetch-executable')
Package is ESM-only since v0.17.0. Named import; no default export.
kubectl
import { kubectl } from 'fetch-executable/executables'
import { kubectl } from 'fetch-executable'
Shortcut functions are exported from a subpath 'fetch-executable/executables', not the main entry.
fetchExecutable (type)
import type { FetchExecutableOptions } from 'fetch-executable'
TypeScript types are exported for options. No separate @types package needed.

Demonstrates basic usage: download an executable if the local version doesn't match, using URL templating and version check.

import { fetchExecutable } from 'fetch-executable'; await fetchExecutable({ target: './my-exec', url: 'https://example.com/download/my-exec/{version}', version: '1.2.3', versionExecArgs: ['--version'], });
Debug
Known issues
breakingBreaking change in v0.17.0: Package is now ESM-only. CommonJS require() will fail.
fix
Use ESM imports (import { fetchExecutable } from 'fetch-executable') or migrate to the previous v0.16.x if you must use CommonJS.
affects: >=0.17.0
gotchaShortcuts must be imported from subpath 'fetch-executable/executables', not the main module.
fix
Import shortcuts like: import { kubectl } from 'fetch-executable/executables';
affects: >=0.0.0
gotchaIf neither 'version', 'execIsOk', nor 'hashValueUrl' is provided, fetchExecutable will throw a validation error.
fix
Set at least one of these options. For example, provide a version string and versionExecArgs.
affects: >=0.0.0
deprecatedThe 'hashValue' option (direct string) is deprecated in favor of 'hashValueUrl' for fetching hashes from a URL.
fix
Use 'hashValueUrl' option with a URL that returns the expected hash.
affects: >=0.15.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/fetch-executable/index.js from /path/to/project/index.js not supported.
Using CommonJS require() with an ESM-only package (v0.17.0+).
fix
Change to ESM import: replace const { fetchExecutable } = require('fetch-executable') with import { fetchExecutable } from 'fetch-executable' and ensure your project is configured for ESM.
Module not found: Can't resolve 'fetch-executable/executables'
Importing shortcut functions from the wrong path.
fix
Ensure import path is 'fetch-executable/executables' (not 'fetch-executable').
ValidationError: At least one of execIsOk, version, or hashValueUrl must be provided.
Calling fetchExecutable without any version-checking option.
fix
Add a version string or execIsOk function to the options object.
HTTP 404 when downloading from URL with {version} placeholder
URL template may not be resolved properly or the version string contains slashes.
fix
Ensure version does not contain special characters. Use versionExecPostProcess to clean version output if needed.
Upgrade
Version history
0.17.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
fetch-executable — npm install fetch-executable · libregistry