denoland/deno · error · anyhow::Error

Unable to choose binary for

Error message

Unable to choose binary for {}
  Available bins:
{}

What it means

After auto-installing an npm package for `deno x`, Deno must choose which `bin` to execute: first the subpath/package name (maybe_run_local_npm_bin at x.rs:708-717), then — only when the package exposes exactly one bin — that sole binary (x.rs:728-732). When the package has multiple bins and none matches the requested name, x.rs:749-757 fails and lists every available bin name.

Solutions

  1. Choose the binary explicitly with the subpath form: `deno x <pkg>:<binname>` — the error's list shows the valid names.
  2. Install once and run the bin directly: `deno install -g <pkg>` then invoke <binname>.
  3. Check the package's `bin` map on npmjs.com to confirm exact spelling and case.

Example fix

# before
$ deno x some-tool
error: Unable to choose binary for some-tool
  Available bins:
    some-tool-cli
    some-tool-server

# after — pick a bin via subpath
deno x some-tool:some-tool-cli --watch .
Defensive patterns

Strategy: validation

Validate before calling

# Look up the package's bin map before invoking deno x
npm view <pkg> bin --json
# if multiple entries, invoke with the subpath: deno x <pkg>:<chosen-bin>

Prevention

When it happens

Trigger: `deno x <multi-bin-package>` with no :binname suffix, where the package name differs from all of its bin entries (common for scoped packages whose bin names drop the @scope/).

Common situations: Scoped packages (@scope/pkg exposing bins pkg-cli and pkg-server); tools renamed their bins across major versions; running a package seen in docs without its subcommand suffix.

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/6203c3cbb5a641fc. Report an issue: GitHub.

Appendix: source

Thrown at cli/tools/x.rs:749

          None
        };

        if let Some(fallback_name) = fallback_name
          && let Some(exit_code) = maybe_run_local_npm_bin(
            &runner_factory,
            &runner_flags,
            runner_node_resolver,
            runner_npm_resolver,
            fallback_name.as_ref(),
            &unstable_args,
            &forwarded,
          )
          .await?
        {
          return Ok(exit_code);
        }

        Err(anyhow::anyhow!(
          "Unable to choose binary for {}\n  Available bins:\n{}",
          effective_command,
          bin_commands
            .keys()
            .map(|k| format!("    {}", k))
            .collect::<Vec<_>>()
            .join("\n")
        ))
      }
    }
    ReqRefOrUrl::Jsr(jsr_package_req_reference) => {
      let (_new_flags, new_factory) = autoinstall_package(
        ReqRef::Jsr(&jsr_package_req_reference),
        &flags,
        reload,
        command_flags.yes,
        &command_flags.ignore_scripts,
        &factory.deno_dir()?.root,

View on GitHub (pinned to 9ad36f7a2c)