denoland/deno · error

Couldn't find a deno.json, deno.jsonc, jsr.json or jsr.jsonc

Error message

Couldn't find a deno.json, deno.jsonc, jsr.json or jsr.jsonc configuration file in {}.

What it means

`deno publish` discovers what to publish from a deno.json, deno.jsonc, jsr.json or jsr.jsonc in the start directory. This error is the `None` arm of the member-config lookup: `jsr_packages_for_publish()` returned no publishable packages and the start directory itself has no deno.json at all, so publish has nothing to work with. The `{}` in the message is the directory Deno was invoked from (the initial cwd).

Source

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

  let directory_path = cli_options.initial_cwd();
  let mut publish_configs = cli_options.start_dir.jsr_packages_for_publish();
  if publish_configs.is_empty() {
    match cli_options.start_dir.member_deno_json() {
      Some(deno_json) => {
        debug_assert!(!deno_json.is_package() || !deno_json.should_publish());
        if deno_json.json.name.is_none() {
          bail!("Missing 'name' field in '{}'.", deno_json.specifier);
        }
        if !deno_json.should_publish() {
          bail!(
            "Package 'publish' field is false in '{}'.",
            deno_json.specifier
          );
        }
        error_missing_exports_field(deno_json)?;
      }
      None => {
        bail!(
          "Couldn't find a deno.json, deno.jsonc, jsr.json or jsr.jsonc configuration file in {}.",
          directory_path.display()
        );
      }
    }
  }

  if let Some(version) = &publish_flags.set_version {
    if publish_configs.len() > 1 {
      bail!(
        "Cannot use --set-version when publishing a workspace. Change your cwd to an individual package instead."
      );
    }
    if let Some(publish_config) = publish_configs.get_mut(0) {
      let mut config_file = publish_config.config_file.as_ref().clone();
      config_file.json.version = Some(version.clone());
      publish_config.config_file = Arc::new(config_file);
    }

View on GitHub (pinned to f7822238ca)

Solutions

  1. Run `deno publish` from the directory that contains the package's deno.json (or pass `--cwd <package-dir>`), or from the workspace root where member configs are discovered.
  2. If this folder is meant to be a package, create a deno.json with `name`, `version`, and `exports`.
  3. If the package is a workspace member, publish from the member directory so `jsr_packages_for_publish()` resolves it.

Example fix

# before: no config in cwd
cd packages/foo/src && deno publish   # error
# after: run from the package root (or point --cwd at it)
cd .. && deno publish
# or: deno publish --cwd packages/foo
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env bash
set -eu
for f in deno.json deno.jsonc jsr.json jsr.jsonc; do
  [ -f "$f" ] && exit 0
done
echo "no deno/jsr config in $(pwd) — run publish from the package root" >&2
exit 1

Prevention

When it happens

Trigger: Running `deno publish` in a directory with no deno.json/jsr.json of any kind — e.g. a source subdirectory (src/, lib/) of a package whose config sits at the package root, a package.json-only npm project, or a fresh folder. Concretely `cli_options.start_dir.jsr_packages_for_publish()` is empty and `start_dir.member_deno_json()` returns `None`.

Common situations: cd-ing into a subfolder before publishing; CI jobs whose working-directory points at a subfolder while deno.json lives at the repo root or package root; config accidentally renamed (deno.config.json, deno.json.txt); running publish in a folder that only holds test fixtures.

Related errors


AI-assisted analysis of denoland/deno@f7822238ca (2026-08-20). Data as JSON: /api/errors/97025bc12d3309e1. Report an issue: GitHub.