Typescript cannot find module using @ root path syntax in a project created from create-vue
See original GitHub issueI’ve got a weird one. Originally posted in https://github.com/vuejs/create-vue/issues/35
Summary
When creating a project in the new recommended way using npm init vue@3
, @
root path imports show an error in .vue files. @
root path imports work fine inside .ts files. The strange thing is others haven’t been able to reproduce my problem. See the issue mentioned above.
Setup
Visual Studio code - up to date Vue Language Features (Volar) - v0.31.1 TypeScript Vue Plugin (Volar) - v0.31.1 Windows 11
Steps to reproduce
npm init vue@3
Typescript support: yes
Everything else: no
pnpm install (or npm install)
Open App.vue and change an import to use @/
root path syntax. E.g. import TheWelcome from '@/components/TheWelcome.vue'
. I get an error: Cannot find module '@/components/TheWelcome.vue' or its corresponding type declarations.ts(2307)

Things I tried
- Disabling all other plugins
- Uninstalling/reinstalling Volar plugins
- Enabled Take Over Mode
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:35 (8 by maintainers)
Top Results From Across the Web
Cannot find module 'path' Error in TypeScript | bobbyhadz
To solve the "Cannot find module path or its corresponding type declarations" error, install the types for node by running the command npm...
Read more >TypeScript 'cannot find module...' in Vue project - Stack Overflow
Try adding the following into index.d.ts in the project root, works for now. declare module '*.vue' { import Vue from 'vue' export default ......
Read more >cannot find module 'path' or its corresponding type ... - You.com
When creating a new app with TypeScript, any imports using absolute path syntax '@/' show as errors in Visual Studio Code with the...
Read more >Vue.js | WebStorm Documentation - JetBrains
js app is the create-vue official Vue project scaffolding tool, which WebStorm downloads and runs for you using npx. You can still use...
Read more >How To Generate a Vue.js Single Page App With the Vue CLI
vue create vue-starter-project. The highlighted section of the command is the name of the root directory of the project.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It seems that Windows will not allow use
"paths": { "@/*":["src/*"] },
, try change it to"paths": { "@/*":["./src/*"] },
.@johnsoncodehk I have the same problem as @alexvoedi in .vue files in projects created from create-vue.
"src/**/*.vue"
is definitely ininclude
in tsconfig.tsconfig: