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
- Clear the package manager cache (npm cache verify / clean) and retry so a fresh, intact tarball is fetched.
- Pin a known-good version of the temporary package instead of latest.
- Verify the package actually ships a bin: npm view <pkg> bin.
- 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
- Only run temp binaries on packages that publish a bin field.
- Pin versions instead of latest to avoid layout changes.
- Clear the package cache when tarball integrity is suspect.
- Verify package contents with npm view <pkg> bin before scripting.
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
- Unable to load package information from registry.
- Could not find ${level} workspace.
- Invalid config found at ${workspace.filePath}. CLI should be
- Could not find a ${level} workspace. Are you in a project?
- Could not find the '${builderConf}' builder's node package.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/4911f57604565cc5.
Report an issue: GitHub.