
npm install -g @vue/cli
vue create explorer
example.zip
Can you reproduce it in plain TypeScript?
@HerringtonDarkholme you open https://github.com/vuejs/vetur/files/1910017/example.zip

I cannot reproduce it.
Same problem here.
Can anybody help?

Without @ it works:

https://github.com/vuejs/vetur/blob/master/docs/FAQ.md#vetur-cant-recognize-components-imported-using-webpacks-alias
https://github.com/vuejs/vetur/blob/master/docs/FAQ.md#vetur-cant-recognize-components-imported-using-webpacks-alias
same problem 😥

this also seems to be a problem on our end as well
im getting this as well:

https://github.com/vuejs/vetur/blob/master/docs/FAQ.md#vetur-cant-recognize-components-imported-using-webpacks-alias
this didnt seem to work for me:
json
// webpack
module.exports = {
resolve: {
alias: {
'@': 'src'
}
}
}
@k1nghat I clarified the doc, sorry:
// If you have below Webpack config
module.exports = {
resolve: {
alias: {
'@': 'src'
}
}
}
// You need such tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": [
"src/*"
]
}
}
}
i get this when i put it into vue.config.js and try to build:
ERROR Invalid options in vue.config.js: "resolve" is not allowed
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@k1nghat No, my point was "if you have such webpack.config.js" you need to create a tsconfig.json in your project root. vue.config.js is an abstraction on top of webpack.config.js.
Can you clone this repo https://github.com/octref/veturpack to create a repro case?
@k1nghat No, my point was "if you have such webpack.config.js" you need to create a
tsconfig.jsonin your project root.vue.config.jsis an abstraction on top ofwebpack.config.js.Can you clone this repo https://github.com/octref/veturpack to create a repro case?
since the last couple updates pushed recently i havent seen the issue in my project or the cloned veturpack repo.
@Grewamor Are you on Windows too?
I start to doubt it's because Windows's specific path handling problem.
Yes, windows
I also encounter this issue, but seems like a window reload fixes it, so surely it isn't just Windows being Windows, right? 😅
I also encounter this issue, but seems like a window reload fixes it, so surely it isn't just Windows being Windows, right? 😅
A window-reload does fix the Problem!
And it's not only a Windows problem... getting the same behavior on Mac.
I'm having this issue as well with everything except the .vue modules.
I already have the "@/*" path in tsconfig.json (it was there by default when I created the project, I believe), and no amount of restarting VSCode or even doing "git clean -fdx" and reinstalling npm packages seems to make any difference. Getting the same thing both on my laptop and my desktop machine.
I am facing this issue as well in .vue files
issue in .vue files

no issue in .ts files

same

just for disable this warnings i use direct path

I am also experiencing this issue on Mac.
VS Code: 1.35.0
Vetur: 0.21.0
In a typical generated Home.vue:

I'm having the same issue, on Windows


I'm having the same issue, on Windows

Brothers, I've found a temporary solution. Turning off this option is not a good way, but it can make the code look good.
Same issue here:
package.json has
"vue": {
"configureWebpack": {
"resolve": {
"alias": {
"@": "src"
}
}
}
tsconfig
{
"compilerOptions": {
"paths": {
"@/*": [
"src/*"
]
}
}
}
inspected webpack config from vue ui shows
resolve: {
alias: {
'@': 'src',
vue$: 'vue/dist/vue.runtime.esm.js'

Today, I emptied the vscode workspace. Open a project, and it's normal, no error.
The folder client contains a vue project created by vue-cli
The folder empty contains only a empty tsconfig.json
works fine:

Cannot find module '@/components/HelloWorld.vue':

The only difference is order
gif:

I'm also having the same issue, and haven't found a workaround yet.
tsconfig:
{
"compilerOptions": {
"paths": {
"@/*": [
"src/*"
]
}
}
}
app.vue:
<script lang="ts">
import * as MyStore from '@/store/mystore'
Yields error
Cannot find module '@/store/mystore'. Vetur(2307)
If anyone finds a fix for this, I'd be super appreciative.
VSCode: 1.36.0
Vetur: 0.21.1
vue: 2.5.16
EDIT:
It looks like the problem resolves if, from VSCode -> File -> Open Folder, I select the root of my Vue app. The Vue app is within a larger monorepo. If I instead Open Folder the folder above the root of my Vue app, the problem persists. What is happening here? Is it looking for tsconfig.json in the root of my workspace? Or does it walk up the directory tree from each file, looking for tsconfig.json?
@DavidXenakis Nice find! I can confirm what he said in his EDIT ... Fix please!
I just found it doesn't pick up the tsconfig.json changes immediately. You need a simple VSCode restart (command+shift+p and then Reload Window).
That fixed it for me. :)
Any fix for this bug?

I can confirm that changing the order of folders in the workspace fixes the issue. It appears that if the Vue app is not the first folder in the workspace then the error occurs.
Try t o create a file named jsconfig.json (not a tsconfig.json) on project root:
{
"compilerOptions": {
"paths": {
"@/*": [
"src/*"
]
}
},
"exclude": ["node_modules"]
}
Can also confirm, changing the order of folders in my workspace solved the problem. Thanks, @bhillis!
@bhillis Reordering works!! But it is a weird fix.
Hey all, I seem to be experiencing the same thing on macOS 10.14.6 with VSCode 1.38.0 and Vetur 0.22.2.
I have a single jsconfig.json in my root project directory for my javscript project. No other workspaces or folders open.
Basically, if I want to leave Vetur's vetur.validation.script set to true I get the following with a webpack lazy import/load in my Vue SFC (single-file-component):

I like to leave Vetur validation on because I can benefit from JSDoc typings to improve my JavaScript experience.
Nothing on this thread has worked for me.
If you are using TypeScript, you need to use the tsconfig.json file.
If you are using TypeScript, you need to use the
tsconfig.jsonfile.
I'm not using TypeScript. I have the Typescript validation turned on to take advantage of JSDoc hints.
Me too, @josephessin , but it's working for me.
@robsonsobral I wish I could say the same. The code base I'm working in is rather large but I might try to to reproduce in a smaller repo
I don't know if this fits in with the issue mentioned here (especially with the open folder find) but under the FAQ for setting up [js|ts]config.json and webpack it does say that you need the .vue extension if you're importing a SFC. Added this to a couple of import statements and the errors go away for me.
https://github.com/vuejs/vetur/blob/master/docs/FAQ.md#vetur-cannot-recognize-my-vue-component-import-such-as-import-comp-from-comp
I hope that is something that get changed / fixed as that is painful to go and fix everywhere.
I can confirm that changing the order of folders in the workspace fixes the issue. It appears that if the Vue app is not the first folder in the workspace then the error occurs.
As mentioned above I trivially found the fix to physically drag my folder to the top of the folder tree so it doesn't look for another ts.config above it. That fixed it for me but that is a slightly worrying fix because it means whatever is causing the underlying issue has not been fixed.
I am using Emacs 26.1, lsp, and vue-language-server 0.0.61. Getting the same error. I am writing a Nuxt app so the following was already inside tsconfig.json:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": ["types/*"],
"~/*": [
"./*"
],
"@/*": [
"./*"
]
}
}
}
I get the following error.

EDIT: Could this error possibly have to do with the fact that my tsconfig.json is not at project root, but rather inside a client directory? Or does it not matter?
Any fixes?

just reopen vs code and it get fixed
EDIT: Could this error possibly have to do with the fact that my
tsconfig.jsonis not at project root, but rather inside aclientdirectory? Or does it not matter?
For me, yes! I had to keep the jsconfig.json at project root.
Still having this problem with Vetur 0.22.6, VSCode 1.39.2.
Physically re-ordering the folders in the workspace can help unless multiple folders are Vue projects, in which case the last one shows the errors.
Opening each folder in its own workspace works and no errors are shown. Basically with the current state of things I just have given up on using a VSCode workspace with multiple folders.
Might be related: https://github.com/vuejs/vetur/issues/815
Upgrade and restart vscode works.
Can confirm what others have been mentioning. If I open the vue-client folder inside my monorepo imports are working fine. If I open the whole monorepo, Vetur is complaining about the imports.


tsconfig.json
{
"files": ["src/typings/shims-vue.d.ts"],
"compilerOptions": {
"sourceMap": true,
"target": "es5",
"experimentalDecorators": true,
"module": "esNext",
"jsx": "preserve",
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"importHelpers": true,
"allowJs": true,
"baseUrl": ".",
"paths": {
"~/*": ["./*"],
"src/*": ["src/*"]
},
"esModuleInterop": true,
"lib": ["es2015", "esnext", "dom", "dom.iterable", "scripthost"]
},
"include": ["src/**/*.ts", "src/**/*.vue", "test/**/*.ts", "./typings"],
"exclude": ["node_modules/**", ".quasar", "dist"]
}
edit:
It seems like multi-root and sub-folder support is on the roadmap for v 1.0
https://github.com/vuejs/vetur/issues/873
As @rdhelms suggests, this is probably related to #815
Timeline for fix??
Head melting away!
I have same problem

"compilerOptions": {
"allowJs": true,
"moduleResolution": "node",
"module": "commonjs",
"target": "es6",
"baseUrl": ".",
"paths": {
"@/*": [
"*"
]
}
}
in .ts file it's all right with alias "@"

The problem in .vue file!
The folder
clientcontains a vue project created by vue-cli
The folderemptycontains only a empty tsconfig.jsonworks fine:
Cannot find module '@/components/HelloWorld.vue':
The only difference is order
gif:
Very effective, solved my problem
The Question is not by theme ... sorry
How to enable this notifications in VS Code?

Waiting for the fix here...
So, what I've gathered from all this:
At the present time Vetur does not support such use cases. The best you can do is vote for this feature (Multi-root and Sub-folder support) at #873, help implement it or wait for it. And try to follow the team's recommendations, like opening the subfolder directly instead of the project. Vetur will only work if your Vue project is at the top-level.
"../../components/my-component.vue"I solved this problem
in .eslintrc.js
add '@typescript-eslint/no-var-requires': 0 in the options of rules

I'm having same issue. Non of any solution solved my problem except using relative paths.
The following worked for me:
My TypeScript client is in the projects subdirectory web. In this subdirectory I have my tsconfig.json. I left the tsconfig.json untouched, but added a new jsconfig.json to the projects root as @robsonsobral suggested. Then I added "baseUrl": "./web", so my jsconfig.json looks like this:
{
"compilerOptions": {
"baseUrl": "./web",
"paths": {
"@/*": ["src/*"]
}
},
"exclude": ["node_modules"]
}
You might have to reload the window or restart VSCode.
I do not have a multiroot workspace, but this might work too, if you specify baseUrl correctly. If you have multiple js/ts roots, I guess this will not work.
For now, the quickest fix for this error is to rearrange your folder structure in VS Code.
To fix:
Manually drag your Vue App's Folder to the top of your opened projects inside of your VS Code workspace.
As mentioned by @cyberbit and @philanderson888
I could fix this issue by just appending .vue to file path I was importing from (doc)
So, instead of
import MyComponent from "@/components/MyComponent"
write
import MyComponent from "@/components/MyComponent.vue"
I hope it helps somebody else :pray:
I solved this problem.
The reason was that <script lang="ts"></script> was missing in the Vue file to be imported.
// components/HelloWorld.vue
<template>
...
</template>
<script lang="ts"></script> // added
// index.vue
<template>
...
</template>
<script lang="ts">
import HelloWorld from "@/components/HelloWorld.vue"; // OK
....
</script>
it
Well it works for me. After I deleted the import statement and rewrite it. I believe this is the problem of vetur and vscode. Let hope this bug will be fixed in the next update.
waiting fix here......... 😢
Using VSCode/Vetur, I receive this error when importing from TypeScript files through an alias, however Vue components seem to work just fine.
In webpack config:
alias : {
'@store': path.resolve(__dirname, './ClientApp/store')
}
In tsconfig:
"paths": {
"@store/*": ["ClientApp/store"]
}
Nothing seems to help. I have an alias for importing components set up identically which has no issues.
For now, the quickest fix for this error is to rearrange your folder structure in VS Code.
To fix:
Manually drag your Vue App's Folder to the top of your opened projects inside of your VS Code workspace.
As mentioned by @cyberbit and @philanderson888
This really help me!
I open a big folder contains my vue project and get this error.
When I try to open my vue project in VSCode everything work fine!
I am using vim with vim-lsp and vim-lsp-settings. I was able to solve the problem by making sure the language server is started from the sub-directory where tsconfig.json lives and not the .git/ root, which was the default. Then everything worked fine. For further details see https://github.com/mattn/vim-lsp-settings/issues/212
如果你是中文环境,请不要把工程文件夹放在有【中文】或者【带空格】的目录文件夹中,在中文环境下刚开始是正常的,过段时间就会出错。出错原因不明。
DO NOT PUT your project directory into none ascii drictory, or the directory name has a space charactor,if you put your directory into that environment, at beginning, it may be ok, but after some time, it will appear that error indicator.
标签:无法正常识别@,无法正常识别注入的$router,$message等变量
Label: Can't recognize @, can't recgnize $router or $message DI variable

For now, the quickest fix for this error is to rearrange your folder structure in VS Code.
To fix:
Manually drag your Vue App's Folder to the top of your opened projects inside of your VS Code workspace.
As mentioned by @cyberbit and @philanderson888
This fixed it for me. Thank you! :)
I had two different projects on the same workspace. I just moved the project, which was having this problem, to the top and that made it work ¯_(ツ)_/¯
Hi all,
having the same issue. Quick fix mentioned by @cyberbit and @philanderson888 was not successful.
I have removed all other repos from my VSCode but still have the issue.
Before stumbling upon this thread I created a StackOverflow post describing my issue.
Feel free to take a look:
https://stackoverflow.com/questions/61426543/cannot-find-module-assets-file-name-here-svg-vue-cli-version-4-2-3-and
Many thanks.
Looking forward to a fix!
I am seeing this as long as I have lang="ts" on my script tag in my component:
<script lang="ts">
import NavBar from '~/components/NavBar'
export default {
}
</script>
So, what I've gathered from all this:
If you're in a monorepo/multi-root setup
At the present time Vetur does not support such use cases. The best you can do is vote for this feature (Multi-root and Sub-folder support) at #873, help implement it or wait for it. And try to follow the team's recommendations, like opening the subfolder directly instead of the project. Vetur will only work if your Vue project is at the top-level.
If you're not in a multi-root setup (your Vue project is at the top-level)
- Try restarting the window.
- Double check your root jsconfig.json/tsconfig.json. Make sure you're following the docs on project setup and path mappping.
- As a last resort, you can use relative paths, e.g.
"../../components/my-component.vue"
I've figured out a workaround for this. My company has a monorepo with the client being located a few directories down. You can use multi-root workspaces to get it working, the only requirement is that the Vue project is the first entry in the folders array:
{
"folders": [
{
"name": "Vetur Project",
"path": "./packages/web"
},
{
"name": "Monorepo",
"path": "."
},
]
}
I'm not sure how it works internally, but I'm guessing VSCode treats the first project as the root project or something? Vetur sees this and then all of the path mappings and stuff work fine on my end. And because of the workspace, I have access to the rest of the monorepo
I assume this will only work for one Vue project though. If you have multiple Vue packages, then this won't work. You'll either need to create a workspace for each Vue package, or suffer 😢
@LucianoFromTrelew adding .vue to the import doesn't resolve the import properly for hinting. It just resolves it to vue typing file which is equally as useless unfortunately (at least this is what happens in my case).

@codemonkey800 Thanks that worked for now :) I have actually been using workspaces, but putting it as the first item seems to have fixed it 🎉 I had to modify my workspace file directly as there seems to be no other way to re-order the workspace directories, and then I had to restart VSCode to get it completely working 🎉 This will be a nice work-around while working on an app in a monorepo.
In my case, removing lang="ts" has (weirdly) fixed the problem!
@7kemZmani Removing lang="ts"removed the linted errors for me as well, neat!
But I'm afraid that removing the lang attribute may potentionally be causing other problems. Wouldn't it?

Edit: Through simply googling just
lang="ts"
you can quickly stumble upon threads that is about the very same issue that we discuss here.
@7kemZmani It isn't a a fix because the original problem is that TypeScript path mapping isn't working. Removing lang="ts" will treat code in the <script> block as JavaScript
@codemonkey800 I have a multi-root workspace and I've found myself switching the order of the folders as I'm working on them 🤦♂️
I have the same problem, but with node_modules package. The package is installed, the code is working, but vetur throws error Cannot find module 'vue-flickity'.Vetur(2307)
I solved this problem.
The reason was that<script lang="ts"></script>was missing in the Vue file to be imported.// components/HelloWorld.vue <template> ... </template> <script lang="ts"></script> // added// index.vue <template> ... </template> <script lang="ts"> import HelloWorld from "@/components/HelloWorld.vue"; // OK .... </script>
I had the same issue while using lang=ts. What fixed it for me was adding .vue to the end of the file as @LucianoFromTrelew suggested .
This problem is very annoying, would be perfect once it'll supoort monorepo
I also get Cannot find module '@/use/use-boards'. Vetur(2307) error.
Possible solution: read the tsconfig.json that closest to the file (not in the root).
boards.vue:

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

the folder:

I have the same problem when use monerepo. recommend to fix it quickly as monerepo is very popular!
Please follow #424, #815
So, what I've gathered from all this:
If you're in a monorepo/multi-root setup
At the present time Vetur does not support such use cases. The best you can do is vote for this feature (Multi-root and Sub-folder support) at #873, help implement it or wait for it. And try to follow the team's recommendations, like opening the subfolder directly instead of the project. Vetur will only work if your Vue project is at the top-level.
If you're not in a multi-root setup (your Vue project is at the top-level)
- Try restarting the window.
- Double check your root jsconfig.json/tsconfig.json. Make sure you're following the docs on project setup and path mappping.
- As a last resort, you can use relative paths, e.g.
"../../components/my-component.vue"I've figured out a workaround for this. My company has a monorepo with the client being located a few directories down. You can use multi-root workspaces to get it working, the only requirement is that the Vue project is the first entry in the
foldersarray:{ "folders": [ { "name": "Vetur Project", "path": "./packages/web" }, { "name": "Monorepo", "path": "." }, ] }I'm not sure how it works internally, but I'm guessing VSCode treats the first project as the root project or something? Vetur sees this and then all of the path mappings and stuff work fine on my end. And because of the workspace, I have access to the rest of the monorepo
I assume this will only work for one Vue project though. If you have multiple Vue packages, then this won't work. You'll either need to create a workspace for each Vue package, or suffer 😢
Thank you, this is working for me w/ latest vetur + vscode
@andy3520's solution also worked for me.
To the Vetur devs: it seems that this whole thing is based on some configuration assumptions (single root project...) - if getting the whole feature to work in all situations is difficult, maybe at least show some further details in the error message (something like "Cannot find module xxxxxx, searched in yyyy, zzzz."
It's incredibly useful to devs to know what magic is going on under the hood....
Getting the same problem... removing lang="ts" fixes the Vetur error but of course disables TypeScript so is not an option... I don't have a multi-root workspace, just a normal folder-based project. No fix I've found has worked yet.
Never mind... be sure to reload the window between every attempt to fix, apparently that was all I needed.
What would it take to fix this? Do you need help? Please let us know what is needed to fix this issue. This is a real show stopper.
What would it take to fix this? Do you need help? Please let us know what is needed to fix this issue. This is a real show stopper.
I don't think it's a mistake.
In fact most of the time it doesn't work simply because the user isn't set up and it's not user-friendly enough.
Here are the steps to make it all work
tsconfig.json or jsconfig.json) and package.json in project roottsconfig.json or jsconfig.json. moretsconfig.json or jsconfig.json) and package.json.If you follow these steps and it still doesn't work, please open a new issue.
It would be nice to have a reproducible project and steps for us.
I've been planning for the future to make Vetur more user-friendly.
But not until after the monorepo or together.
In my case, removing
lang="ts"has (weirdly) fixed the problem!
it’s can work for me
Any ideas ?
Any ideas ?
https://github.com/vuejs/vetur/issues/762#issuecomment-714200659
Workspace 1
-- Repository 1 - Vue
---- <Here we have this issue>
-- Repository 2 - Laravel
The solution as aforementioned is to open repository #1 in its own workspace, there having the package json at the root of the workspace. But not the real solution.
The style of two repos in same workspace is very typical for decoupled solutions and API integrations between two projects.
762 is the solution as for now, however not the real solution as this doesn't solve the issue with these types of workspaces:
Workspace 1 -- Repository 1 - Vue ---- <Here we have this issue> -- Repository 2 - LaravelThe solution as aforementioned is to open repository #1 in its own workspace, there having the package json at the root of the workspace. But not the real solution.
The style of two repos in same workspace is very typical for decoupled solutions and API integrations between two projects.
This project does not support workspace at this time.
It's deviating from the issue.
Please follow #2377
Any ideas ?
This solution not working, I have tsconfig.json with:
...
"paths": {
"@/*": [
"src/*"
]
},
...
and still I have an error:
_Cannot find module '@/components/table/TableComponent.vue' or its corresponding type declarations.Vetur(2307)_
Any ideas ?
This solution not working, I have
tsconfig.jsonwith:... "paths": { "@/*": [ "src/*" ] }, ...and still I have an error:
_Cannot find module '@/components/table/TableComponent.vue' or its corresponding type declarations.Vetur(2307)_
if you set baseUrl?
You can provide a reproducible project.
@yoyo930021
if you set
baseUrl?
You can provide a reproducible project.
I have baseUrl. My tsconfig.json file:
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env",
"jest"
],
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.vue",
"tests/**/*.ts",
"tests/**/*.tsx"
],
"exclude": [
"node_modules"
],
"files": [
"./src/shims-vue.d.ts"
]
}
@yoyo930021
if you set
baseUrl?
You can provide a reproducible project.I have
baseUrl. Mytsconfig.jsonfile:{ "compilerOptions": { "target": "esnext", "module": "esnext", "strict": true, "jsx": "preserve", "importHelpers": true, "moduleResolution": "node", "skipLibCheck": true, "esModuleInterop": true, "allowSyntheticDefaultImports": true, "sourceMap": true, "baseUrl": ".", "types": [ "webpack-env", "jest" ], "paths": { "@/*": [ "src/*" ] }, "lib": [ "esnext", "dom", "dom.iterable", "scripthost" ] }, "include": [ "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", "tests/**/*.tsx" ], "exclude": [ "node_modules" ], "files": [ "./src/shims-vue.d.ts" ] }
Please provide a reproducible project.
https://github.com/vuejs/vetur/blob/master/.github/NO_REPRO_CASE.md
Otherwise we don’t have enough information to help you.
In my cases, add file extension solve the problem
bad:
import Hello from '@/component/Hello'
good:
import Hello from '@/component/Hello.vue'
see: https://github.com/vuejs/vetur/blob/master/docs/FAQ.md#vetur-cannot-recognize-my-vue-component-import-such-as-import-comp-from-comp
In my cases, add file extension solve the problem
bad:
import Hello from '@/component/Hello'good:
import Hello from '@/component/Hello.vue'see: https://github.com/vuejs/vetur/blob/master/docs/FAQ.md#vetur-cannot-recognize-my-vue-component-import-such-as-import-comp-from-comp
I was already doing this and it does not work. It is driving me nut's. Anyone found a solution already?
如果你是中文环境,请不要把工程文件夹放在有【中文】或者【带空格】的目录文件夹中,在中文环境下刚开始是正常的,过段时间就会出错。出错原因不明。
DO NOT PUT your project directory into none ascii drictory, or the directory name has a space charactor,if you put your directory into that environment, at beginning, it may be ok, but after some time, it will appear that error indicator.
标签:无法正常识别@,无法正常识别注入的$router,$message等变量
Label: Can't recognize @, can't recgnize $router or $message DI variable
it works for me. just make sure your workspace is the root directory of your project
I get the "Cannot find module ___ or its corresponding type declarations" error in Vetur, but the project itself compiles and works just fine. I don't get this error in .ts files, only in .vue files (using the same reference path). So everything works, but I don't get type safety in .vue files because anything I import looks like an 'any' type.
I get the "Cannot find module ___ or its corresponding type declarations" error in Vetur, but the project itself compiles and works just fine. I don't get this error in .ts files, only in .vue files (using the same reference path). So everything works, but I don't get type safety in .vue files because anything I import looks like an 'any' type.
Please provide a reproducible project.
https://github.com/vuejs/vetur/blob/master/.github/NO_REPRO_CASE.md
Otherwise we don’t have enough information to help you.
And check path alias first char isn't slash for #2525
I experienced the same problem as soon as I needed to move my root directory into a ./src directory (eg. nuxt deployment in firebase). Namely, all my @/components/MyComponent.vue could not be found and I could no longer navigate to them.
Workaround (not a solution) for VS Code
If I open VS code directly from the ./src directory as your root directory everything worked for me again. This was acceptable for me because, during development, I only need to work on this directory.
So instead of this:
cd /Users/myuser/projectName && code .
I did this:
cd /Users/myuser/projectName/src && code .
I experienced the same problem as soon as I needed to move my root directory into a
./srcdirectory (eg. nuxt deployment in firebase). Namely, all my@/components/MyComponent.vuecould not be found and I could no longer navigate to them.Workaround (not a solution) for VS Code
If I open VS code directly from the./srcdirectory as your root directory everything worked for me again. This was acceptable for me because, during development, I only need to work on this directory.So instead of this:
cd /Users/myuser/projectName && code .Do this:
cd /Users/myuser/projectName/src && code .
Where are your tsconfig.json/jsconfig.json?
You can keep in the opened project root or use vetur.config.js
Facing the same problem (ie. having 2 tsconfig.json: one for the client, one for the server), I found this vetur configuration, but I can't really make it work.
Is it a dead-end or am I just clumsy at configuration?
EDIT: As a workaround, what I ended up doing was to configure my root tsconfig for my client application, and letting in the server app a tsconfig with a "extends": "../../tsconfig.json",, re-setting the server-side specific configuration
- [x] I have searched through existing issues
I find #545 and #423, but error is still exists.- [x] I have read through docs
- [x] I have read FAQ
Info
- Platform: Win
- Vetur version : 0.11.7
- VS Code version:1.22.1
Problem
Reproducible Case
npm install -g @vue/cli
vue create explorer
example.zip
=============================
Please use absolute path like this:

Instead of:

Please keep in mind that you don't need to use .ts for import them like .vue files, like this:_

Most helpful comment
I am facing this issue as well in .vue files
issue in .vue files

no issue in .ts files
