Skip to content
Latchkey

TS2792: Cannot find module - try moduleResolution node - in CI

tsc could not resolve a module and suggests that your moduleResolution (or paths) setting is the cause.

What this error means

Type-checking fails with TS2792, explicitly recommending a moduleResolution change or paths aliases.

tsc
src/svc.ts(1,19): error TS2792: Cannot find module 'node:fs'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?

Common causes

How to fix it

Use a modern moduleResolution

  1. Set moduleResolution to bundler, node16, or nodenext to match your runtime
tsconfig.json
{
  "compilerOptions": {
    "module": "nodenext",
    "moduleResolution": "nodenext"
  }
}

Add paths aliases

  1. Declare baseUrl and paths for any custom specifiers
tsconfig.json
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": { "@/*": ["src/*"] }
  }
}

How to prevent it

  • Choose a moduleResolution that matches your module format and keep paths aliases in sync with imports.

Related guides

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