denoland/deno · error

{} is missing 'version' field

Error message

{} is missing 'version' field

What it means

JSR requires every published package to carry an explicit version in its deno.json — there is no per-publish version argument on the registry path. During prepare_publish the package's deno.json is read; a missing "version" field aborts that package.

Source

Thrown at cli/tools/publish/mod.rs:492

            );
          }
        }
        Ok(diagnostics_by_folder.into_graph())
      }
    }
  }

  async fn prepare_publish(
    &self,
    package: &JsrPackageConfig,
    graph: Arc<deno_graph::ModuleGraph>,
    diagnostics_collector: &PublishDiagnosticsCollector,
  ) -> Result<Rc<PreparedPublishPackage>, AnyError> {
    let deno_json = &package.config_file;
    let config_path = deno_json.specifier.to_file_path().unwrap();
    let root_dir = config_path.parent().unwrap().to_path_buf();
    let version = deno_json.json.version.clone().ok_or_else(|| {
      deno_core::anyhow::anyhow!(
        "{} is missing 'version' field",
        deno_json.specifier
      )
    })?;
    let (scope, name_no_scope) = registry::parse_package_name(&package.name)?;
    let file_patterns = package.member_dir.to_publish_config()?.files;

    let tarball = deno_core::unsync::spawn_blocking({
      let diagnostics_collector = diagnostics_collector.clone();
      let module_content_provider = self.module_content_provider.clone();
      let cli_options = self.cli_options.clone();
      let config_path = config_path.clone();
      let config_url = deno_json.specifier.clone();
      let has_license_field = package.license.is_some();
      let current_package_name = package.name.clone();
      move || {
        let root_specifier =
          ModuleSpecifier::from_directory_path(&root_dir).unwrap();

View on GitHub (pinned to 89f33cbef2)

Solutions

  1. Add a semver "version" (e.g. "1.0.0") to the deno.json of the package being published
  2. In workspaces, ensure each publishable member's config carries its own version
  3. Let the CLI stamp it during publish with --set-version 0.2.0, or bump via your release tool before publishing

Example fix

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

Strategy: validation

Validate before calling

grep -q '"version"' deno.json || { echo 'deno.json is missing "version" — required for publish' >&2; exit 2; }
deno publish --dry-run

Prevention

When it happens

Trigger: `deno publish` (including --dry-run) for a workspace member or single package whose deno.json omits "version".

Common situations: Single-package repos assuming publish takes a version flag; workspaces where only the root config has a version; release tooling that has not stamped the version yet.

Related errors


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