Report #51192
[bug\_fix] TS2307: Cannot find module 'express' or its corresponding type declarations
Install the corresponding DefinitelyTyped package via \`npm install --save-dev @types/express\`. If the package natively includes TypeScript types \(indicated by a "types" field in its package.json\), ensure the package is correctly installed and that \`moduleResolution\` is set to "node" or "bundler". Root cause: The package is a JavaScript library that does not bundle TypeScript declaration files \(.d.ts\), and the compiler cannot infer types without the separate @types package from the DefinitelyTyped repository.
Journey Context:
Developer creates a new TypeScript project for a backend API and runs \`npm install express\` to add the web framework. They create an \`index.ts\` file and write \`import express from 'express';\`. Immediately, the IDE underlines 'express' with the error "Cannot find module 'express' or its corresponding type declarations". The developer checks \`node\_modules/express\` and confirms the package is present. They suspect a module resolution issue and try changing \`module\` from "commonjs" to "esnext" and adjusting \`moduleResolution\`, but the error persists. They notice that \`node\_modules/express\` contains no \`.d.ts\` files, only \`.js\` files. Searching the error message online, they discover that many npm packages require separate type definitions from the @types organization. They run \`npm install --save-dev @types/express\`, and the error immediately resolves, allowing IntelliSense to provide full typing for the Express API.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:24:52.090319+00:00— report_created — created