Fix "Error: Cannot find module" in Node, Next.js & Cursor projects
Quick answer: A package isn't installed, the import path is wrong, or the file name casing differs.
Error: Cannot find module
Why it happens
A package isn't installed, the import path is wrong, or the file name casing differs. It's one of the most common errors in AI-generated projects because AI tools often add imports or packages without updating your install or config.
How to fix it
- Run npm install (or pnpm/yarn install) in the project root.
- If it's a package, install it: npm install <name>.
- If it's a local file, check the relative path and exact capitalization.
- Delete node_modules and package-lock.json, then reinstall if it persists.
Prompt to paste into your AI tool
I got this error: "Error: Cannot find module". Before changing any code, explain the root cause in 2 sentences, list the files involved, then propose the smallest fix.
Still stuck? Paste your exact error into the free Error Fixer.