denoland/deno · error · TypeError

Unexpected 'name' field in options, bench name is already…

Error message

Unexpected 'name' field in options, bench name is already provided as the first argument

What it means

`deno uninstall` first resolves the installation directory (`$DENO_INSTALL_ROOT/bin`, default `~/.deno/bin`, honoring `--root`), then checks `fs::metadata`: if something exists at that path but it is not a directory (a regular file or symlink to a file), it aborts before touching any package shims. The check exists because the uninstall loop joins package names onto this path and would misbehave on a file.

Solutions

  1. Check what exists at the path: `ls -la "$DENO_INSTALL_ROOT"` (default `~/.deno`)
  2. Fix `DENO_INSTALL_ROOT` to point at a real directory (deno appends `bin` unless the path already ends with it)
  3. Remove or rename the stray file occupying the `bin` path
  4. Pass `--root <dir>` explicitly to target the directory where the packages were actually installed

Example fix

# before (DENO_INSTALL_ROOT points at a file)
export DENO_INSTALL_ROOT=/usr/local/bin/deno
deno uninstall cowsay  # Installation path is not a directory

# after
export DENO_INSTALL_ROOT=$HOME/.deno
deno uninstall cowsay  # removed
Defensive patterns

Strategy: validation

Validate before calling

# Verify the install bin dir resolves to a directory before uninstalling
BIN_DIR="${DENO_INSTALL_ROOT:-$HOME/.deno}"
BIN_DIR="${BIN_DIR%/bin}/bin"
[ -d "$BIN_DIR" ] || { echo "bad install dir: $BIN_DIR"; exit 1; }
deno uninstall "$PKG"

Prevention

When it happens

Trigger: `deno uninstall <pkg>` when `$DENO_INSTALL_ROOT` (or `$DENO_INSTALL_ROOT/bin`, or the `--root` value) resolves to an existing non-directory: e.g. `DENO_INSTALL_ROOT=/usr/local/bin/deno` (a file), or a stray file named `bin` inside the configured root.

Common situations: Misconfigured `DENO_INSTALL_ROOT` in shell profile pointing at a binary instead of a directory; Docker/dotfiles that create the root incorrectly; `--root` given a file path by a wrapper script.

Related errors


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

Appendix: source

Thrown at cli/js/40_bench.js:130

  };

  if (typeof nameOrFnOrOptions === "string") {
    if (!nameOrFnOrOptions) {
      throw new TypeError("The bench name can't be empty");
    }
    if (typeof optionsOrFn === "function") {
      benchDesc = { fn: optionsOrFn, name: nameOrFnOrOptions, ...defaults };
    } else {
      if (!maybeFn || typeof maybeFn !== "function") {
        throw new TypeError("Missing bench function");
      }
      if (optionsOrFn.fn != undefined) {
        throw new TypeError(
          "Unexpected 'fn' field in options, bench function is already provided as the third argument",
        );
      }
      if (optionsOrFn.name != undefined) {
        throw new TypeError(
          "Unexpected 'name' field in options, bench name is already provided as the first argument",
        );
      }
      benchDesc = {
        ...defaults,
        ...optionsOrFn,
        fn: maybeFn,
        name: nameOrFnOrOptions,
      };
    }
  } else if (typeof nameOrFnOrOptions === "function") {
    if (!nameOrFnOrOptions.name) {
      throw new TypeError("The bench function must have a name");
    }
    if (optionsOrFn != undefined) {
      throw new TypeError("Unexpected second argument to Deno.bench()");
    }
    if (maybeFn != undefined) {

View on GitHub (pinned to 9ad36f7a2c)