denoland/deno · error

Missing name in config

Error message

Missing name in config

What it means

While generating the package.json that `deno pack` embeds in the tarball, Deno requires the package name from deno.json. A config without "name" cannot produce a valid package.json, so generation aborts.

Source

Thrown at cli/tools/pack/package_json.rs:68

  exports: Option<serde_json::Value>,
  // BTreeMap (not HashMap): serde_json walks BTreeMap in sorted key
  // order, so the generated package.json — and therefore the tarball
  // bytes — are identical across runs even with multiple deps. See the
  // `reproducible` spec test.
  #[serde(skip_serializing_if = "Option::is_none")]
  dependencies: Option<BTreeMap<String, String>>,
}

pub fn generate_package_json(
  config_file: &ConfigFile,
  version: &str,
  files: &[ProcessedFile],
) -> Result<String, AnyError> {
  let name = config_file
    .json
    .name
    .as_ref()
    .ok_or_else(|| deno_core::anyhow::anyhow!("Missing name in config"))?;

  let dts_set = dts_available_set(files);

  let exports = convert_exports(&config_file.json.exports, &dts_set)?;
  let (main, types) =
    extract_main_and_types(&config_file.json.exports, &dts_set);

  // Collect dependencies from all files. BTreeMap so the serialized
  // package.json keys come out in sorted order (reproducibility).
  let mut dependencies: BTreeMap<String, String> = BTreeMap::new();

  // Merge dependencies from all processed files
  for file in files {
    for (name, version) in &file.dependencies {
      dependencies.insert(name.clone(), version.clone());
    }
  }

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Add "name" to the deno.json of the package being packed
  2. Verify you are packing the intended workspace member whose config actually carries identity

Example fix

// deno.json before
{ "version": "1.0.0", "exports": "./mod.ts" }
// after
{ "name": "pkg", "version": "1.0.0", "exports": "./mod.ts" }
Defensive patterns

Strategy: validation

Validate before calling

grep -q '"name"' deno.json || { echo 'deno.json is missing "name" — pack cannot generate package.json' >&2; exit 2; }
deno pack

Prevention

When it happens

Trigger: `deno pack` on a deno.json lacking "name" — the same precondition as the default-filename error, hit on the package.json generation path.

Common situations: Unnamed workspace members; config files that only define tasks/imports; incremental adoption of pack in existing repos.

Related errors


AI-assisted analysis of denoland/deno@89f33cbef2 (2026-08-16). Data as JSON: /api/errors/779a133dd8b18315. Report an issue: GitHub.