Registry / devops / npm-install-fetch

npm-install-fetch

JSON →
library1.3.14jsnpmunverified

npm-install-fetch (v1.3.14, last updated 2024) is a Node.js API and CLI tool for automatically fetching external resources during the npm install step. It helps keep npm package distribution sizes small by downloading large binary assets or archives on install instead of bundling them. Key differentiators: supports YAML config, platform/architecture filtering, decompression, archive extraction with path mapping, and multiple resources per package. Unlike other fetch-on-install tools, it integrates tightly with npm's lifecycle scripts and offers both CLI and package.json configuration.

npm install npm-install-fetch
INSTALL
IMPORT
SIG · NPM-INSTALL-FETCH
N
npm-install-fetch
devopsjavascriptv1.3.14
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.

npm-install-fetch CLI
npx npm-install-fetch -n "My Resource" -o output.tgz https://example.com/resource.tar.gz
npm install-fetch -n "My Resource" -o output.tgz https://example.com/resource.tar.gz
Use npx or a script entry in package.json; the command is npm-install-fetch, not install-fetch.
Programmatic API
import { installFetch } from 'npm-install-fetch'; await installFetch({ input: 'https://...', output: './out' });
const installFetch = require('npm-install-fetch');
The package is ESM-only since v1.0; CommonJS require is not supported. Use ES module imports.
Configuration in package.json
{ "npm-install-fetch": { "name": "My Resource", "input": "https://...", "output": "./out" } }
{ "install-fetch": { ... } }
The config key must be exactly 'npm-install-fetch', not just 'install-fetch'.

Shows how to add npm-install-fetch as a devDependency and configure it via the install script to fetch a tar.gz archive into example.tgz.

// package.json { "scripts": { "install": "npm-install-fetch -n \"Example 1.2.3\" -o example.tgz https://github.com/example/example/archive/1.2.3.tar.gz" }, "devDependencies": { "npm-install-fetch": "^1.3.0" } } // Then run: // npm install // (fetches example.tgz during install)
Debug
Known issues
breakingVersion 1.0 changed from CJS to ESM. CommonJS require() will not work.
fix
Use ESM imports: import { installFetch } from 'npm-install-fetch';
affects: >=1.0
deprecatedCLI option --decompress is deprecated, use --extract with --strip and --filter instead.
fix
Replace --decompress with --extract and adjust --strip/--filter as needed.
affects: >=1.2
gotchaThe package must be in devDependencies, not dependencies, to avoid including it in production bundles.
fix
Add npm-install-fetch to devDependencies in package.json.
affects: *
gotchaIf used with npm@7+ workspaces, the install script may run in each workspace; ensure paths are correct.
fix
Use absolute paths or __dirname in the install script.
affects: >=1.0
Errors
Common errors & fixes
Error: Cannot find module 'npm-install-fetch'
The package is not installed or is in optional peer dependencies.
fix
Run 'npm install --save-dev npm-install-fetch' to ensure it's in devDependencies.
SyntaxError: Unexpected token 'export'
CJS code trying to require() an ESM-only module.
fix
Use import syntax or use dynamic import() inside your CJS script.
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! npm-install-fetch: install: `npm-install-fetch ...`
The install script failed, often due to invalid URL or no network access.
fix
Check the URL, ensure network connectivity, and verify the output path is writable.
Upgrade
Version history
1.3.14latest on npm
Audit
Dependencies
noderequiredRequires Node.js >=12
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
npm-install-fetch — npm install npm-install-fetch · libregistry