denoland/deno · error
No deno.json found in current directory
Error message
No deno.json found in current directory
What it means
`deno pack` found no JSR packages in the workspace and no deno.json in the current directory, so there is nothing to pack. This is the `None` arm of the member deno.json lookup: `jsr_packages_for_publish()` was empty and `member_deno_json()` returned None.
Source
Thrown at cli/tools/pack/mod.rs:97
"Missing 'exports' field in '{}'. Add an exports field like:\n {{\n \"exports\": \"./mod.ts\",\n ...\n }}",
deno_json.specifier
);
}
packages.push(JsrPackageConfig {
name,
member_dir: cli_options.start_dir.workspace.root_dir().clone(),
config_file: deno_json.clone(),
license: deno_json
.json
.license
.as_ref()
.and_then(|l| l.as_str().map(|s| s.to_string())),
should_publish: true,
});
}
None => {
bail!("No deno.json found in current directory");
}
}
}
let module_graph_creator = cli_factory.module_graph_creator().await?;
let parsed_source_cache = cli_factory.parsed_source_cache()?;
for package in packages {
// Validate package name format
if !package.name.starts_with('@') || !package.name.contains('/') {
bail!(
"Invalid package name '{}'. Package name must be in the format '@scope/name'",
package.name
);
}
log::info!(
"{} {}",View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Run `deno pack` from the directory that contains (or should contain) the package's deno.json.
- Create a deno.json with name/version/exports in the current directory if this is the package root.
- If packages live in workspace members, ensure each member deno.json has a `name` so they register as JSR packages.
Example fix
# before: no config in cwd
deno pack
# after: scaffold minimal config first
cat > deno.json <<'EOF'
{
"name": "@scope/pkg",
"version": "1.0.0",
"exports": "./mod.ts"
}
EOF
deno pack Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from "node:fs";
if (!existsSync("deno.json") && !existsSync("deno.jsonc")) {
console.error("nothing to pack: create deno.json first");
process.exit(1);
}
deno pack; Prevention
- Run pack from the package directory, not arbitrary subfolders.
- Keep one deno.json per publishable package with a `name` so workspace discovery finds it.
- Fail fast in scripts when the expected config file is absent.
When it happens
Trigger: Running `deno pack` in a directory with neither deno.json nor any publishable workspace member (e.g. a plain folder, a node-only project, or a subdirectory of the workspace).
Common situations: Running the command from the wrong directory (workspace root of a multi-member workspace where members hold the packages). A folder with only .ts files and no config; a package.json-only npm project. Intentionally initializing a package before creating config.
Related errors
- Missing 'name' field in '{}'. Add a package name like: {
- Missing 'version' field in '{}'. Add a version like: {
- Missing 'exports' field in '{}'. Add an exports field like:
- unsupported 'exports' shape in deno.json: expected a string
- No deno.json or package.json in "{}".
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/89608c5de1e4d1fe.
Report an issue: GitHub.