angular/angular-cli · error · Error

Cannot locate bin for temporary package: ${packageNameNoVers

Error message

Cannot locate bin for temporary package: ${packageNameNoVersion}.

What it means

Thrown by runTempBinary after a temporary npm package has been fetched and unpacked but no executable bin entry could be resolved inside it. The CLI spawns the package's bin via node, and if the package's package.json lacks a usable bin (string or map) or the referenced file is missing, binPath stays undefined and this error is thrown.

Source

Thrown at packages/angular/cli/src/commands/update/utilities/cli-version.ts:149

    const pkgLocation = join(workingDirectory, 'node_modules', packageNameNoVersion);
    const packageJsonPath = join(pkgLocation, 'package.json');

    // Get a binary location for this package
    let binPath: string | undefined;
    if (existsSync(packageJsonPath)) {
      const content = await fs.readFile(packageJsonPath, 'utf-8');
      if (content) {
        const { bin = {} } = JSON.parse(content) as { bin: Record<string, string> };
        const binKeys = Object.keys(bin);

        if (binKeys.length) {
          binPath = resolve(pkgLocation, bin[binKeys[0]]);
        }
      }
    }

    if (!binPath) {
      throw new Error(`Cannot locate bin for temporary package: ${packageNameNoVersion}.`);
    }

    const { status, error } = spawnSync(process.execPath, [binPath, ...args], {
      stdio: 'inherit',
      env: {
        ...process.env,
        NG_DISABLE_VERSION_CHECK: 'true',
        NG_CLI_ANALYTICS: 'false',
      },
    });

    if (status === null && error) {
      throw error;
    }

    return status ?? 0;
  } finally {
    await cleanup();

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Clear the package manager cache (npm cache verify / clean) and retry so a fresh, intact tarball is fetched.
  2. Pin a known-good version of the temporary package instead of latest.
  3. Verify the package actually ships a bin: npm view <pkg> bin.
  4. Check registry/proxy integrity if tarballs are repeatedly corrupted.

Example fix

// before
runTempBinary('some-lib@latest', ...)  // some-lib has no bin
// after
runTempBinary('some-cli@1.2.3', ...)  // package that declares bin
Defensive patterns

Strategy: try-catch

Validate before calling

const bin = JSON.parse(execSync(`npm view ${pkg} bin --json`, {encoding:'utf8'}) || 'null');
if (!bin) throw new Error(`${pkg} does not expose a bin; it cannot be run as a temporary CLI`);

Try / catch

try {
  await runTempBinary(`${pkg}@${version}`, args);
} catch (e) {
  if (e.message.includes('Cannot locate bin for temporary package')) {
    // clear cache and retry, or fall back to installing the package locally and using its bin
  }
}

Prevention

When it happens

Trigger: The package being executed via npx-style temp install publishes no bin field, or its bin points to a non-existent file; the unpacked package layout differs from what the bin map declares; passing a package name that resolves to a library rather than a CLI tool.

Common situations: Running `ng update` flows that shell out to temp CLIs (e.g. migrations tooling) against a broken or mispublished package version; proxy/registry serving a corrupted tarball; package renamed bins in a newer version while a cached copy is used.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/4911f57604565cc5. Report an issue: GitHub.