Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeScript 'cannot find module...' in Vue project

I'm using TypeScript in Vue project.

But when I try to import vue file, I can't get .vue file since the 'cannot find module...' error.

enter image description here

What is weird is that intellisense only shows the directory right upper the .vue file.

Intellisense shows the directory well Intellisense shows the directory well

But it doesn't show the .vue file inside it But it doesn't show the .vue file inside it

I also have vue-shim.d.ts file in root directory.

like image 940
HK S0 Avatar asked Feb 02 '26 20:02

HK S0


2 Answers

You should install TypeScript Vue Plugin and Vue Language Features.

like image 96
pirooz jenabi Avatar answered Feb 04 '26 09:02

pirooz jenabi


Try adding the following into index.d.ts in the project root, works for now.

declare module '*.vue' {
    import Vue from 'vue'
    export default Vue
}

or try to configure the path in tsconfig with

"paths": { "@/*":["./src/*"] }

or edit includes in tsconfig with

"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"] 
like image 38
Ahmed Malek Avatar answered Feb 04 '26 10:02

Ahmed Malek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!