Cannot resolve TypeScript type declaration for ECMAScript Module (.d.mts)
Environment:
- New project → Vue.js
- Vite 7 (released June 24, 2025)
- TypeScript with ESM declarations (
.d.mts) (previously.d.tsin Vite 6)
Issue:
In vite.config.ts:
import vue from '@vitejs/plugin-vue'WebStorm shows this problem:
Vue: Cannot find module @vitejs/plugin-vue or its corresponding type declarations.
There are types at
./node_modules/@vitejs/plugin-vue/dist/index.d.mts
, but this result could not be resolved under your current moduleResolution setting. Consider updating to node16, nodenext, or bundlerNote:
My tsconfig.json already has moduleResolution set to bundler:
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "bundler",
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"useDefineForClassFields": true,
"types": ["node", "vite/client"],
"allowImportingTsExtensions": true,
"resolveJsonModule": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}
Build and run work fine without any errors—this problem only appears in the IDE.
Question:
How can I get WebStorm (or TypeScript/Vue engine) to properly resolve .d.mts files?
请先登录再写评论。
It works for me with
vite@7.0.3:As far as I can see, both
index.d.mtsandindex.d.tsare available in@vitejs/plugin-vue/dist:What is a result of running
vue-tscfor your app?Hi,
vue-tscshows no errors.There are
.d.tsfiles in Vite as well, but it seems the IDE isn’t picking them up.This problem happens with every
.d.mtsdeclaration, including ones from Tailwind CSS.Sure, I’ve uploaded it to GitHub: luyiourwong/mtxtest: sample project for intellij support #27973940568082
This project was basically created from New Project with just a few small modifications to setup TypeScript.
The
tsconfig.jsonis configured based on the official Vue documentation:https://vuejs.org/guide/typescript/overview.html#configuring-tsconfig-json
Thank you!
The corresponding
moduleResolutionis indeed configured in thetsconfig.json, but thevite.config.tsthe error is reported for is not included in it. Adding this file to theinclude:list should help:Thank you, this was helpful. I hadn’t considered it could be related to it since the warning pointed to external references. Appreciate your help!