Common errorsBlogSponsor

Cursor "Error: Cannot find module": how to fix it

What it means

Your app is trying to use a piece of code (a "package") that isn't installed, or it's looking in the wrong folder for a file. Cursor's AI often adds an import without installing the package.

How to fix it

  1. Look at the name in quotes after "Cannot find module" (for example 'axios').
  2. If it's a package name, open the terminal in Cursor and run npm install axios (swap in your package name).
  3. If it starts with ./ or ../, it's a file path. Ask Cursor: "Check that this file exists and fix the import path. Don't change anything else."
  4. Restart your dev server (npm run dev).

FAQ

Why does Cursor say "Cannot find module"?

Your code imports a package or file that isn't there. Usually Cursor's AI added an import but never installed the package.

How do I fix "module not found" in Cursor?

If it's a package name, run npm install plus the package name in the terminal. If it's a file path, ask Cursor to fix the import path without changing anything else.

Do I need to restart after installing a package?

Yes. Stop the dev server and run npm run dev again so your app picks up the new package.

Still stuck? Paste your exact error into Unstuck and get one fix prompt written for Cursor. Your first 3 fixes are free.

Get my fix prompt — 3 free