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:15Common 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
- Fix the import to a resolvable specifier (URL, path, or
npm:/jsr:). - Add it to the import map if it is a shared bare name.
- Re-run
deno check.
Terminal
deno check main.tsProvide 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 checklocally so TS2307 surfaces before CI.
Related guides
Deno check TypeScript type errors (TS...) in CIFix Deno "error: TS...." type-check failures in CI - deno check reports TypeScript diagnostics that fail the…
Deno "fmt --check ... Not formatted" gate failing in CIFix Deno "error: Found N not formatted files" from deno fmt --check in CI - files do not match the formatter…
Deno lint failures (deno lint) in CIFix deno lint failures in CI - deno lint reports rule violations that exit non-zero and fail the lint gate.