Common causes
- The npm package isn't installed — run npm install to get it
- The @types package for the library isn't installed (e.g., @types/express for express)
- A relative import path is wrong or the file doesn't exist at that path
- The module's package.json doesn't include a types field and there's no DefinitelyTyped package
How to fix it
- Install the package if missing: npm install package-name
- Install type declarations: npm install --save-dev @types/package-name
- Check the relative import path — make sure the file exists and the path is correct
- If no @types package exists, add a declaration file: create module.d.ts with declare module 'module-name'
Example
import express from 'express';
// error TS2307: Cannot find module 'express' or its corresponding type declarations.Importing express before installing @types/express alongside the package
Browse more errors
The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.
