TypeScript error

TS2307: An import the checker cannot resolve

  • Error TS2307
  • Tested with TypeScript 5.9

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

CodeTS2307
MessageCannot find module '{0}' or its corresponding type declarations.
TypeScript's categoryerror
Listed underModules 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

app.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: app.js(2,29): error TS2307: Cannot find module '@example/price-format' or its corresponding type declarations. app.js(4,20): error TS2307: Cannot find module './cart.module.css' or its corresponding type declarations. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. app.js(2,29): error TS2307: Cannot find module '@example/price-format' or its corresponding type declarations. app.js(4,20): error TS2307: Cannot find module './cart.module.css' or its corresponding type declarations. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. app.js(2,29): error TS2307: Cannot find module '@example/price-format' or its corresponding type declarations. app.js(4,20): error TS2307: Cannot find module './cart.module.css' or its corresponding type declarations. checked 21 October 2026
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)}`;
A package that is not installed, and a CSS module.
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's paths.

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.

app.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
import { formatPrice } from "@example/price-format";
import styles from "./cart.module.css";

export const label = `${styles.total}: ${formatPrice(1999)}`;
The package installed with its types, and a declaration for CSS modules.
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 types list in jsconfig.json does not stop imports from finding @types packages; it only limits which ones load as globals.
  • When module is set to an ES year without moduleResolution, packages in node_modules are not looked up the usual way and the error is TS2792, which says so.
  • Relative imports under nodenext without an extension are TS2835, not TS2307.

Sources

Last reviewed 20 October 2026.