npm_install_helpers.ts view source
(pm_cli: string, options?: InstallCacheHealingOptions): Promise<NpmCommandResult> import {install_with_cache_healing} from '@fuzdev/gro/npm_install_helpers.js'; Installs dependencies, self-healing the stale-cache (ETARGET) failure mode.
Strategy:
- First attempt:
${pm_cli} install [...install_args]. - On an npm ETARGET-class failure (stale cache):
npm cache clean --forcethen retry the same install once. - On any other failure — or any failure under a non-npm
pm_cli— return immediately without healing.
Why ETARGET happens: right after a dependency is published and the
registry has propagated, npm's local cache may still hold stale
"404"/no-version metadata for it; clearing the cache forces a fresh metadata
fetch. This makes installs safe to run immediately after publishing an
upstream package — e.g. picking up a just-released dep in a
dependency-ordered publish chain, or gro upgrade-ing to a fresh @latest.
npm only: the heal uses npm-specific syntax (cache clean --force), so
it's gated on pm_cli === 'npm'. A non-npm pm_cli surfaces the failure
unchanged rather than running a command it can't understand.
The env is always passed through sanitize_install_env so the build's devDependencies survive.
pm_cli
the npm-compatible CLI to run (e.g. config.pm_cli)
stringoptions
cwd, env, logger, extra install args, and an injectable runner
{}returns
Promise<NpmCommandResult> the result of the (possibly retried) install