denoland/deno · error
Missing 'name' field in '{}'. Add a package name like: {
Error message
Missing 'name' field in '{}'. Add a package name like:
{
"name": "@scope/package-name",
...
} What it means
`deno pack` requires the current directory's deno.json to declare a `name` because it packs exactly one JSR-style package when no workspace members are found. Without a name the package cannot be identified on JSR. The error shows the config file's specifier and a `@scope/package-name` example.
Source
Thrown at cli/tools/pack/mod.rs:66
// Check if git repository is clean (unless --allow-dirty)
if !pack_flags.allow_dirty
&& let Some(dirty) =
crate::util::git::check_if_git_repo_dirty(cli_options.initial_cwd()).await
{
bail!(
"Git repository has uncommitted changes. Use --allow-dirty to pack anyway.\n{}",
dirty
);
}
// Get package configs
let mut packages = cli_options.start_dir.jsr_packages_for_publish();
if packages.is_empty() {
match cli_options.start_dir.member_deno_json() {
Some(deno_json) => {
let Some(name) = deno_json.json.name.clone() else {
bail!(
"Missing 'name' field in '{}'. Add a package name like:\n {{\n \"name\": \"@scope/package-name\",\n ...\n }}",
deno_json.specifier
);
};
if deno_json.json.version.is_none() {
bail!(
"Missing 'version' field in '{}'. Add a version like:\n {{\n \"version\": \"1.0.0\",\n ...\n }}",
deno_json.specifier
);
}
if deno_json.json.exports.is_none() {
bail!(
"Missing 'exports' field in '{}'. Add an exports field like:\n {{\n \"exports\": \"./mod.ts\",\n ...\n }}",
deno_json.specifier
);
}
packages.push(JsrPackageConfig {View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Add `"name": "@scope/package-name"` to deno.json.
- If this directory is part of a workspace, run `deno pack` from the member directory that owns the package config, or make the deno.json a workspace member with a name.
- Verify you are in the intended directory (`pwd`) — the check uses the CLI's start dir.
Example fix
// deno.json (before)
{
"exports": "./mod.ts"
}
// deno.json (after)
{
"name": "@scope/package-name",
"exports": "./mod.ts"
} Defensive patterns
Strategy: validation
Validate before calling
// Check required pack fields before invoking deno pack
import { readFileSync } from "node:fs";
const cfg = JSON.parse(readFileSync("deno.json", "utf8"));
if (!cfg.name) {
console.error("deno.json is missing required field: name");
process.exit(1);
} Type guard
const hasName = (cfg: unknown): boolean => typeof cfg === "object" && cfg !== null && "name" in cfg && typeof (cfg as any).name === "string";
Prevention
- Use a package template that includes name/version/exports from the start.
- Validate deno.json in CI (deno publish --dry-run) before packing.
- Keep required manifest fields in a checklist when scaffolding packages.
When it happens
Trigger: Running `deno pack` in a standalone directory whose deno.json has no `"name"` field and where `jsr_packages_for_publish()` returned no workspace packages.
Common situations: A new module bootstrapped with `deno init` (its default deno.json has no name); converting an existing script folder into a publishable package without filling in package metadata.
Related errors
- Missing 'version' field in '{}'. Add a version like: {
- Missing 'exports' field in '{}'. Add an exports field like:
- No deno.json found in current directory
- unsupported 'exports' shape in deno.json: expected a string
- Missing name
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/ffd2a7fb56059011.
Report an issue: GitHub.