denoland/deno · error

Missing 'name' field in config file.

Error message

Missing 'name' field in config file.

What it means

When Deno converts a workspace member's config file into a deno_graph WorkspaceMember, it requires a top-level "name" string. A member's deno.json without a name field bails with this message; a "version", if present, must additionally parse as a standard semver string.

Source

Thrown at cli/args/mod.rs:1691

      deno_path_util::resolve_url_or_path(import_map_path, current_dir)
        .map_err(|source| ImportMapSpecifierResolveError { source })?;
    Ok(Some(specifier))
  } else {
    Ok(None)
  }
}

/// Resolves the no_prompt value based on the cli flags and environment.
pub fn resolve_no_prompt(flags: &PermissionFlags) -> bool {
  flags.no_prompt || has_flag_env_var(&CliSys::default(), "DENO_NO_PROMPT")
}

pub fn config_to_deno_graph_workspace_member(
  config: &ConfigFile,
) -> Result<deno_graph::WorkspaceMember, AnyError> {
  let name: StackString = match &config.json.name {
    Some(name) => name.as_str().into(),
    None => bail!("Missing 'name' field in config file."),
  };
  let version = match &config.json.version {
    Some(version) => {
      Some(deno_semver::Version::parse_standard(version).with_context(
        || format!("Invalid 'version' field in '{}'", config.specifier),
      )?)
    }
    None => None,
  };
  Ok(deno_graph::WorkspaceMember {
    base: config.specifier.join("./").unwrap(),
    name,
    version,
    exports: config.to_exports_config()?.into_map(),
  })
}

pub fn get_default_v8_flags() -> Vec<String> {

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Add a top-level "name": "your-package" to the member's deno.json
  2. If a "version" is present, make it a valid standard semver string
  3. Check every member listed under "workspace" in the root config - the fault may be in any of them

Example fix

// before (member deno.json)
{ "version": "1.0.0", "exports": "./mod.ts" }

// after
{ "name": "@scope/pkg", "version": "1.0.0", "exports": "./mod.ts" }
Defensive patterns

Strategy: validation

Validate before calling

// Validate all workspace members before running publish/build
const root = JSON.parse(await Deno.readTextFile("deno.json"));
for (const member of root.workspace ?? []) {
  const cfg = JSON.parse(await Deno.readTextFile(new URL(member, "file://" + Deno.cwd() + "/").href));
  if (typeof cfg.name !== "string" || cfg.name.length === 0) {
    throw new Error(`${member}/deno.json is missing a top-level "name" field`);
  }
}

Type guard

const isNamedConfig = (cfg: unknown): cfg is { name: string } =>
  typeof (cfg as { name?: unknown })?.name === "string" && (cfg as { name: string }).name.length > 0;

Prevention

When it happens

Trigger: A workspace whose root config lists members under "workspace", and one of the member deno.json files lacks the "name" field when workspace resolution walks it.

Common situations: Adding packages to a deno workspace and forgetting name; authors assuming package.json-style tooling makes name optional; JSONC edits that accidentally remove the field.

Related errors


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