user14131782
user14131782

Reputation: 1068

Vite + Vue3 new project - Cannot find module './App.vue' or its corresponding type declarations

I have just created a new Vite + Vue3 project using npm init vue@latest.

On loading the project in VSCode, I get the following error in Main.ts, when importing App.vue:

Cannot find module './App.vue' or its corresponding type declarations

The app seems to work fine, so I assume this is an issue with my VSCode config. Does anyone know how to resolve this?

Upvotes: 11

Views: 5888

Answers (1)

user14131782
user14131782

Reputation: 1068

I resolved this by enabling Volar's takeover mode, a more performant alternative to the older extension option. Follow these steps:

  1. Open the command palette (ctrl+shift+p in Windows)
  2. Type 'Extensions: Show Built-in Extensions'
  3. Search for 'TypeScript and JavaScript Language Features' in the extensions tab that has appeared
  4. Select 'Disable (workspace)' (click on the arrow to the right of the 'Disable' button)
  5. Open the command palette again and enter 'Developer: Reload Window'

Upvotes: 12

Related Questions