Skip to content
Latchkey

Deno check "TS2307 Cannot find module or its type declarations" in CI

During deno check, the type checker could not resolve a module specifier or find type declarations for it. The import may be wrong, unmapped, or an npm package without bundled types.

What this error means

The check step fails with "error: TS2307 [ERROR]: Cannot find module \"X\" or its corresponding type declarations." pointing at the import line.

deno
error: TS2307 [ERROR]: Cannot find module "npm:some-lib" or its corresponding type declarations.
import x from "npm:some-lib";
              ~~~~~~~~~~~~~~~
    at file:///home/runner/work/app/app/src/main.ts:1:15

Common causes

The specifier does not resolve for the type checker

A bare or mistyped specifier, or one not in the import map, cannot be found by deno check.

An npm package ships no type declarations

The package has no bundled types and no matching @types resolution, so the checker cannot find declarations.

How to fix it

Correct or map the specifier

  1. Fix the import to a resolvable specifier (URL, path, or npm:/jsr:).
  2. Add it to the import map if it is a shared bare name.
  3. Re-run deno check.
Terminal
deno check main.ts

Provide types for an untyped npm package

Point Deno at a types package with an @deno-types directive, or install the matching @types package via npm:.

src/main.ts
// @deno-types="npm:@types/some-lib"
import x from "npm:some-lib";

How to prevent it

  • Keep imports resolvable and mapped in deno.json.
  • Add type directives for npm packages without bundled types.
  • Run deno check locally so TS2307 surfaces before CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →