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

  1. Run npm install (or pnpm/yarn install) in the project root.
  2. If it's a package, install it: npm install <name>.
  3. If it's a local file, check the relative path and exact capitalization.
  4. 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.

Get the free "10 Prompts That Fix Broken AI Code" pack

Join the FixKit AI newsletter: one short email a week with real errors from Cursor, Lovable, Bolt & Replit users and how to fix them. Unsubscribe anytime.

Newsletter signup powered by beehiiv. We only use your email to send the newsletter.