← Back to Error Library
ImportErrorTypeScriptApr 2026

Cannot find module '../utils/format' or its corresponding type declarations

Error Message

terminal
error TS2307: Cannot find module '../utils/format' or its corresponding type declarations.
  at src/components/Card.ts:1:21

Root Cause

The tsconfig.json did not include the utils/ directory in paths or include, so TypeScript could not resolve the import even though the file was physically there.

Fix

solution
// tsconfig.json — add baseUrl and paths alias
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
  },
  "include": ["src/**/*"]
}

// Now import with the alias
import { formatDate } from '@/utils/format'

Takeaway

TypeScript module resolution depends on baseUrl, paths, and include in tsconfig.json. When a file exists but TS still can't find it, check the config — not the path.

TypeScripttsconfigModule Resolution