Cant not find module
When the page is first opened, an error occurs("is not a module"), but the module can still be found. After opening the folder under this module, the error disappears.
there are my tsconfig.json and Webstorm typescript config
And my webstorm version is WebStorm 2024.3.1
What can i do to fix the errors?{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"jest"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
],
"resolveJsonModule": true
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
]
}



请先登录再写评论。
Do you have a sample project you can share that reproduces it?
Elena Pogorelova Thanks for your answer. Here is a reproducible example.
Step 1: You need to clone this github project https://github.com/davidyell/Learning-Vue2-Typescript/tree/master/src
Step 2: You need to create a new folder and then have a ts file in it
Step 3: You need to import this method
Step 4: Restart the vue & eslint service of webstorm
Unfortunately I failed to reproduce the issue with the specified steps:
All can see is ESLint errors related to formatting. Module is successfully recognized, I didn't need to restart the services
Elena Pogorelova
Sorry, I didn't describe it clearly. You can try this.
You need to close the api tab and restart the vue service to reproduce it.
When the api page tab exists, the module can be found
Here is what it looks like for me - I didn't open the
api.ts
at all during this session:Have you already restart vue server?
My computer is Windows, is yours a Mac? Does this matter?
I did restart it; and I'm on Windows: