denoland/deno · error

module could not be found

Error message

module could not be found

What it means

`deno info <specifier>` resolved the root specifier, but the graph lookup returned ModuleErrorKind::Missing — the module itself could not be loaded: the file does not exist at the resolved path, or a remote (http/https) module was never cached and fetching failed. The root of the dependency tree is absent, so there is nothing to display.

Source

Thrown at cli/tools/info.rs:610

          writer,
          "{} {} unique",
          colors::bold("dependencies:"),
          dep_count,
        )?;
        writeln!(
          writer,
          "{} {}",
          colors::bold("size:"),
          display::human_size(total_size),
        )?;
        writeln!(writer)?;
        let root_node = self.build_module_info(root, false);
        root_node.print(writer)?;
        Ok(())
      }
      Err(err) => {
        if let ModuleErrorKind::Missing { .. } = err.as_kind() {
          bail!("module could not be found");
        } else {
          bail!("{:#}", err);
        }
      }
      Ok(None) => {
        bail!("an internal error occurred");
      }
    }
  }

  fn build_dep_info(&mut self, dep: &Dependency) -> Vec<DisplayTreeNode> {
    let mut children = Vec::with_capacity(2);
    if !dep.maybe_code.is_none()
      && let Some(child) = self.build_resolved_info(&dep.maybe_code, false)
    {
      children.push(child);
    }
    if !dep.maybe_type.is_none()

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Verify the specifier exists (ls the file, or curl the URL)
  2. For remote modules, cache it first with network access: `deno cache <url>` or `deno install`, then retry `deno info <url>`
  3. Fix the path — run from the project root or use a specifier relative to the correct cwd

Example fix

# before
deno info ./src/main.ts   # run from wrong cwd -> module could not be found

# after
cd /path/to/project && deno info src/main.ts
# or, for a remote module that was never cached:
deno cache https://example.com/mod.ts && deno info https://example.com/mod.ts
Defensive patterns

Strategy: validation

Validate before calling

# local file: assert existence first
test -f src/main.ts && deno info src/main.ts
# remote module: pre-cache with network before offline info
deno cache https://example.com/mod.ts && deno info https://example.com/mod.ts

Try / catch

Wrap `deno info <spec>`; on 'module could not be found' check existence (fs stat or curl -I), re-cache remote specifiers (`deno cache <url>`), then retry once.

Prevention

When it happens

Trigger: `deno info ./does_not_exist.ts`; `deno info https://example.com/mod.ts` while offline with an empty DENO_DIR cache; running info from a different cwd so a relative specifier resolves to a missing path; the remote module was deleted or renamed upstream.

Common situations: Typos in the path; running `deno info` from the wrong directory; first-ever run on a machine with no cache and no network; a CDN URL that moved.

Related errors


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