denoland/deno · error

Missing name

Error message

Missing name

What it means

`deno pack` computes the default tarball filename (name-version.tgz) from the package name in deno.json. If the config has no "name" field there is nothing to derive a filename from, so the command aborts before writing anything.

Source

Thrown at cli/tools/pack/npm_tarball.rs:27

use super::AssetFile;
use super::ProcessedFile;
use super::ReadmeOrLicense;
use super::extensions::js_to_dts_extension;

/// Compute the default tarball filename (`scope-name-version.tgz`) that
/// `pack` writes when no `--output` is given. Extracted so the asset
/// collector can exclude this exact path (instead of guessing by `.tgz`
/// extension) and so the name is computed in exactly one place.
pub fn default_tarball_filename(
  config_file: &ConfigFile,
  version: &str,
) -> Result<PathBuf, AnyError> {
  let name = config_file
    .json
    .name
    .as_ref()
    .ok_or_else(|| deno_core::anyhow::anyhow!("Missing name"))?;
  // Convert @scope/name to scope-name
  let normalized = name.replace('@', "").replace('/', "-");
  // The package name shape is checked against `@scope/name` higher up
  // (see `pack` in mod.rs), but that check is loose — it does not
  // forbid path-traversal sequences. Treat this as a hard safety
  // boundary right before we open a file, rejecting any derived
  // tarball name that contains `..` or path separators so we never
  // escape the cwd regardless of upstream validation drift.
  if normalized.contains("..") || normalized.contains('/') {
    return Err(deno_core::anyhow::anyhow!(
      "refusing to write tarball with unsafe name derived from package: {}",
      name
    ));
  }
  Ok(PathBuf::from(format!("{}-{}.tgz", normalized, version)))
}

/// Tar archive paths must use forward slashes, even on Windows. Output paths

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Add a valid "name" to deno.json (e.g. "@scope/pkg" or "pkg")
  2. Or bypass the default name: deno pack --output out.tgz
  3. In workspaces, ensure the member's own deno.json carries the name

Example fix

// deno.json before
{ "tasks": { "pack": "deno pack" } }
// after
{ "name": "@scope/pkg", "tasks": { "pack": "deno pack" } }
Defensive patterns

Strategy: validation

Validate before calling

# fail fast when the packable config lacks identity
grep -q '"name"' deno.json || { echo 'deno.json is missing "name" — required by deno pack' >&2; exit 2; }
deno pack

Prevention

When it happens

Trigger: Running `deno pack` without --output in a workspace whose deno.json (or the relevant member config) omits "name".

Common situations: deno.json used purely as a task/import map without package identity; multi-member workspaces where pack targets an unnamed member.

Related errors


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