{"record":{"id":"448a721763684e2f","repo":"denoland/deno","slug":"did-not-have-a-bin-entry-for","errorCode":null,"errorMessage":"'{}' did not have a bin entry for '{}'{}","messagePattern":"'(.+?)' did not have a bin entry for '(.+?)'(.+?)","errorType":"exception","errorClass":"AnyError","httpStatus":null,"severity":"error","filePath":"libs/node_resolver/resolution.rs","lineNumber":2704,"sourceCode":"            prefix.push('@');\n            prefix.push_str(version);\n          }\n          prefix\n        })\n        .unwrap_or_default();\n      let keys = bins\n        .keys()\n        .map(|k| {\n          if prefix.is_empty() {\n            format!(\" * {k}\")\n          } else if Some(k.as_str()) == default_bin {\n            format!(\" * {prefix}\")\n          } else {\n            format!(\" * {prefix}/{k}\")\n          }\n        })\n        .collect::<Vec<_>>();\n      bail!(\n        \"'{}' did not have a bin entry for '{}'{}\",\n        package_json.path.display(),\n        searching_bin.unwrap_or(\"<unspecified>\"),\n        if keys.is_empty() {\n          \"\".to_string()\n        } else {\n          format!(\"\\n\\nPossibilities:\\n{}\", keys.join(\"\\n\"))\n        }\n      )\n    }\n  }\n}\n\nfn should_be_treated_as_relative_or_absolute_path(specifier: &str) -> bool {\n  if specifier.is_empty() {\n    return false;\n  }\n","sourceCodeStart":2686,"sourceCodeEnd":2722,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/libs/node_resolver/resolution.rs#L2686-L2722","documentation":"The package.json has bin entries, but neither the explicitly requested name (from an `npm:<pkg>/<name>` selector) nor the default name (derived from the package name) matches any key in the bin map. The bail message appends a 'Possibilities:' list of the actual keys — rendered as `<pkg>` for the default key and `<pkg>/<key>` for the others — so the correct selector is printed right in the error.","triggerScenarios":"`deno run -A npm:<pkg>/<wrong-name>` where wrong-name is not a bin key; or bare `npm:<pkg>` when the bin keys do not include the package's own default name — typical for scoped packages (`@scope/pkg` whose only bin key is `pkg-cli`) and multi-binary packages.","commonSituations":"Scoped packages whose bin key drops the scope; binaries renamed between package versions while scripts keep the old name; multi-tool packages with several bin keys; guessing a bin name without checking package.json first.","solutions":["Read the 'Possibilities:' lines in the error and use one of them: `deno run -A npm:<pkg>/<listed-key>` (for scoped packages the default entry is listed as the bare package name).","Inspect available bins before running: `npm view <pkg> bin`.","If a binary was renamed, update your script/alias to the new name, or pin the older version that shipped the name you use.","For bare `npm:<pkg>` failures, run the explicit selector instead: `deno run -A npm:<pkg>/<actual-key>`."],"exampleFix":"# before\n$ deno run -A npm:@tools/toolbelt lint\n# error: '...package.json' did not have a bin entry for 'lint'\n# Possibilities:\n#  * @tools/toolbelt\n#  * @tools/toolbelt/tb-lint\n\n# after: use a listed possibility\ndeno run -A npm:@tools/toolbelt/tb-lint","handlingStrategy":"validation","validationCode":"// TypeScript/Deno: list the real bin keys before constructing a command\nconst res = await fetch(`https://registry.npmjs.org/${pkg}/latest`);\nconst pkgJson = await res.json();\nconsole.log(Object.keys(pkgJson.bin ?? {})); // pick the selector from these keys","typeGuard":"function hasBinKey(\n  p: { bin?: unknown; name?: string },\n  key: string,\n): boolean {\n  if (typeof p.bin === \"string\") return p.name === key;\n  return typeof p.bin === \"object\" && p.bin !== null && key in p.bin;\n}","tryCatchPattern":"const { stderr, success } = await cmd.output();\nif (!success && new TextDecoder().decode(stderr).includes(\"did not have a bin entry\")) {\n  // the stderr already lists Possibilities: re-run with npm:<pkg>/<listed-key>\n}","preventionTips":["For scoped/multi-binary packages, always use the explicit `npm:<pkg>/<bin-key>` selector.","Pin package versions whose bin keys match your scripts; re-check on major upgrades.","Parse the 'Possibilities:' block from the error — it enumerates every valid selector."],"tags":["npm","bin","package-json","node-compat","cli"],"backgroundTag":"package-bin-not-found","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","contentChangedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}