error TS2307: Cannot find module '@example/price-format' or its corresponding type declarations. is reported when an import (or require, or import() type) names something module resolution cannot find, as a JavaScript or TypeScript file, a package, or a declaration.
Three situations cover most cases: the package is not installed (or not in this folder's node_modules), the path has a typo, or the import is for a non-JavaScript file such as ./cart.module.css that a bundler handles and the checker cannot read.
At a glance
| Code | TS2307 |
|---|---|
| Message | Cannot find module '{0}' or its corresponding type declarations. |
| TypeScript's category | error |
| Listed under | Modules and imports |
| Depends on | moduleResolution, paths |
| In .js files | Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file |
The message is TypeScript's own text from its diagnostic messages file (Apache-2.0); {0} is filled in by tsc for each error.
What it looks like
import { formatPrice } from "@example/price-format";error TS2307: Cannot find module '@example/price-format' or its corresponding type declarations.
import styles from "./cart.module.css";error TS2307: Cannot find module './cart.module.css' or its corresponding type declarations.
export const label = `${styles.total}: ${formatPrice(1999)}`;jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} What causes it
- The package is missing from
node_modules: not installed, installed in another workspace, or removed. - A relative path is wrong (a typo, a moved file, a different case on a case-sensitive file system).
- The import is for a file type the checker does not understand (CSS, images, SVG) and nothing declares what it exports.
- A path alias that the bundler understands (
@/components) is not in the config'spaths.
How to fix it
Install the package; declare the file types the bundler handles
For a package, install it (npm install) in the folder the config belongs to; if it ships JavaScript only, see TS7016. For CSS modules and other assets, add a wildcard module declaration in a .d.ts file that include matches, as the fixed example does for *.module.css.
import { formatPrice } from "@example/price-format";
import styles from "./cart.module.css";
export const label = `${styles.total}: ${formatPrice(1999)}`;jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js", "*.d.ts"]
} Mirror bundler aliases in paths
If the bundler resolves @/... to src/..., add the same mapping under paths in jsconfig.json. The checker never reads the bundler's config.
Side-effect imports
import "./reset.css";, an import with no names, is not reported by default in TypeScript 5.9, even when nothing can be found. The option noUncheckedSideEffectImports turns that check on.
Gotchas
- A
typeslist injsconfig.jsondoes not stop imports from finding@typespackages; it only limits which ones load as globals. - When
moduleis set to an ES year withoutmoduleResolution, packages innode_modulesare not looked up the usual way and the error is TS2792, which says so. - Relative imports under
nodenextwithout an extension are TS2835, not TS2307.
Sources
- Modules Reference: Ambient modules (pattern ambient modules) · TypeScript handbook
- Modules Reference: The moduleResolution compiler option · TypeScript handbook
- diagnosticMessages.json (TypeScript 5.9.3) · TypeScript on GitHub
Last reviewed 20 October 2026.