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
- Set moduleResolution to bundler, node16, or nodenext to match your runtime
tsconfig.json
{
"compilerOptions": {
"module": "nodenext",
"moduleResolution": "nodenext"
}
}Add paths aliases
- 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
TS2307: Cannot find module - in CIFix "error TS2307: Cannot find module 'x' or its corresponding type declarations" when tsc runs in CI - a mis…
TS2691: An import path cannot end with a .ts extension - in CIFix "error TS2691: An import path cannot end with a '.ts' extension. Consider importing './x' instead" in CI.
TS1378: Top-level await requires module/target - in CIFix "error TS1378: Top-level 'await' expressions are only allowed when the 'module' option is ... and the 'ta…