-
-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find module 'xxxx' when using path mapping #762
Comments
Can you reproduce it in plain TypeScript? |
this also seems to be a problem on our end as well |
im getting this as well: this didnt seem to work for me: // 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
|
@k1nghat No, my point was "if you have such webpack.config.js" you need to create a 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 |
@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? 😅 |
A window-reload does fix the Problem! |
I'm having this issue as well with everything except the .vue modules. |
#762 is the solution as for now, however not the real solution as this doesn't solve the issue with these types of workspaces:
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. |
This project does not support workspace at this time. |
This solution not working, I have
and still I have an error: |
if you set |
I have
|
Please provide a reproducible project. |
In my cases, add file extension solve the problem bad: import Hello from '@/component/Hello' good: import Hello from '@/component/Hello.vue' |
I was already doing this and it does not work. It is driving me nut's. Anyone found a solution already? |
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. |
Please provide a reproducible project. 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 Workaround (not a solution) for VS Code So instead of this: I did this: |
Where are your tsconfig.json/jsconfig.json? |
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 |
============================= Use absolute path like : Instead of: ===============Extra tip:Please keep in mind that you don't need to use .ts to import them like .vue files, like : Update: Since Vetur causing this problem, this is just an alternative and temporary way for mapping problem if you want to test and run the project. |
If you set the language to <script lang="js">
...
</script> |
If you also have this issue in the bad {
"compilerOptions": {
...
"paths": {
"@/":["src/"]
}
}
} good {
"compilerOptions": {
...
"baseUrl": "./",
"paths": {
"@/*":["src/*"]
}
}
} |
@ghtali while this is a valid means of circumventing the issue, the question is about resolving the pathmapping error. |
@avinoamsn That's right but since Vetur causing this error, this could be a temporary fix to run your code. I didn't say that using absolute path will fix the problem but it's an alternative to avoid facing mapping problem. |
I was facing this issue, because my Vue Client is inside
|
I encountered this issue and this comment helped Essentially, I had a monorepo set up that didn't have a root-level So, I think there's a Vetur bug around resolving sub-projects (sub-folders with UPDATE: This apparently only fixed it for <script lang="ts">
// Vetur can't resolve, even though TS / Webpack can resolve just fine
import { createClient } from '@/plugins/contentful' |
In case your project's
|
Unfortunately, this way I got some issues with VSCode & Prettier, like disabling code folding and Prettier for vue files.
|
Everyone encounters different problems:
I will lock this issue. |
I find Can't find module about non-relative path #545 and Can fix Intellisense and go to definition for absolute path #423, but error is still exists.
Info
Problem
Reproducible Case
npm install -g @vue/cli
vue create explorer
example.zip
The text was updated successfully, but these errors were encountered: