Coding⏱️ 3 min read📅 2026-06-04

How to Fix: VSCode showing "cannot find module" TS error for .vue import while compiling doesn't

VSCode error Cannot find module '@/components/SidebarToggleIcon' while compiling VueJS project with TypeScript.

Quick Answer: Try checking your system settings or restarting.

VSCode is displaying a 'Cannot find module' error for a .vue import in a VueJS project, but this error does not appear during compilation. This issue affects developers who use VSCode to compile their projects.

This error can be frustrating, especially when it's intermittent and only shows up in the IDE. However, with the right steps, you can resolve this issue and get back to working on your project efficiently.

🛑 Root Causes of the Error

  • The primary cause of this error is likely due to a mismatch between the import path and the actual location of the file in your project directory.
  • Another possible reason for this error could be related to the way VSCode handles module resolution, especially when using TypeScript and VueJS together.

🛠️ Step-by-Step Verified Fixes

Resolving the Error by Correcting Import Paths

  1. Step 1: Open the Command Palette in VSCode and run the command 'Vue: Select Active Template' to ensure you're using the correct template for your project.
  2. Step 2: Check the import path in your SidebarToggleIcon.vue file and verify that it matches the actual location of the file in your project directory. If necessary, update the import path accordingly.
  3. Step 3: Run the command 'Vue: Compile' or 'Ctrl + Shift + Alt + C' to re-compile your project and ensure that the corrected import path is recognized by VSCode.

Resolving the Error by Updating ESLint Configuration

  1. Step 1: Check if you have recently updated your ESLint configuration by running the command 'eslint --init' or checking the eslint.config.json file in your project root.
  2. Step 2: Ensure that the '@vue/eslint-config-typescript' package is installed and configured correctly. If not, install it using npm or yarn and update your ESLint configuration accordingly.
  3. Step 3: Run the command 'eslint .' to re-run ESLint on your project and verify that the updated configuration resolves the 'Cannot find module' error.

💡 Conclusion

By following these steps, you should be able to resolve the 'Cannot find module' error in VSCode for your VueJS project. Remember to always keep your ESLint configuration up-to-date and ensure that your import paths are correct to avoid this issue in the future.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions