Cursor·Fixpromptingbeginner

Cursor Generating Wrong Import Paths

Quick Answer

Cursor doesn't know your project's path aliases unless you tell it via .cursorrules or tsconfig.json. Start with "Add import rules to .cursorrules" before making broader code changes.

You're in the right place if...

  • !Import paths don't resolve
  • !Uses ../../../ instead of @/
  • !Module not found errors

Why this happens

Cursor doesn't know your project's path aliases unless you tell it via .cursorrules or tsconfig.json.

Fix

1

Add import rules to .cursorrules

Specify your import conventions:

Import alias: @ = ./src

Always use:
import { Button } from '@/components/ui/button'

Never use:
import { Button } from '../../../components/ui/button'

Prevent this next time

Include your import alias convention in .cursorrules. Cursor will follow it consistently.

Frequently Asked Questions

A shortcut that means 'start from the src directory'. @ = ./src. Configured in tsconfig.json paths.

../../ paths break when you move files. @ paths always work regardless of file location.

Related fixes

Weekly Newsletter

Get next week's fix before you need it.

Join developers getting weekly vibe coding tips, error fixes, and tool updates.

Subscribe on Substack →