{"record":{"id":"4911f57604565cc5","repo":"angular/angular-cli","slug":"cannot-locate-bin-for-temporary-package-package","errorCode":null,"errorMessage":"Cannot locate bin for temporary package: ${packageNameNoVersion}.","messagePattern":"Cannot locate bin for temporary package: (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/angular/cli/src/commands/update/utilities/cli-version.ts","lineNumber":149,"sourceCode":"    const pkgLocation = join(workingDirectory, 'node_modules', packageNameNoVersion);\n    const packageJsonPath = join(pkgLocation, 'package.json');\n\n    // Get a binary location for this package\n    let binPath: string | undefined;\n    if (existsSync(packageJsonPath)) {\n      const content = await fs.readFile(packageJsonPath, 'utf-8');\n      if (content) {\n        const { bin = {} } = JSON.parse(content) as { bin: Record<string, string> };\n        const binKeys = Object.keys(bin);\n\n        if (binKeys.length) {\n          binPath = resolve(pkgLocation, bin[binKeys[0]]);\n        }\n      }\n    }\n\n    if (!binPath) {\n      throw new Error(`Cannot locate bin for temporary package: ${packageNameNoVersion}.`);\n    }\n\n    const { status, error } = spawnSync(process.execPath, [binPath, ...args], {\n      stdio: 'inherit',\n      env: {\n        ...process.env,\n        NG_DISABLE_VERSION_CHECK: 'true',\n        NG_CLI_ANALYTICS: 'false',\n      },\n    });\n\n    if (status === null && error) {\n      throw error;\n    }\n\n    return status ?? 0;\n  } finally {\n    await cleanup();","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/update/utilities/cli-version.ts#L131-L167","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nrunTempBinary('some-lib@latest', ...)  // some-lib has no bin\n// after\nrunTempBinary('some-cli@1.2.3', ...)  // package that declares bin","handlingStrategy":"try-catch","validationCode":"const bin = JSON.parse(execSync(`npm view ${pkg} bin --json`, {encoding:'utf8'}) || 'null');\nif (!bin) throw new Error(`${pkg} does not expose a bin; it cannot be run as a temporary CLI`);","typeGuard":null,"tryCatchPattern":"try {\n  await runTempBinary(`${pkg}@${version}`, args);\n} catch (e) {\n  if (e.message.includes('Cannot locate bin for temporary package')) {\n    // clear cache and retry, or fall back to installing the package locally and using its bin\n  }\n}","preventionTips":["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."],"tags":["angular-cli","npm","bin","temporary-package"],"backgroundTag":"cannot-locate-package-bin","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}