Skip to content

Typescript cannot find module using @ absolute path syntax Visual Studio Code Volar error #35

@pholly

Description

@pholly

When creating a new app with TypeScript, any imports using absolute path syntax '@/' show as errors in Visual Studio Code with the Volar extension. The app still runs fine.

Steps to reproduce:

IDE: Visual Studio Code
Extension: Volar

npm init vue@3
Typescript support: yes
Everything else: no

pnpm install (or npm install)

Change an import to use @/ absolute syntax, such as in App.vue change the HelloWorld.vue import to import HelloWorld from '@/components/HelloWorld.vue'

There will now be a red line error: Cannot find module '@/components/HelloWorld.vue' or its corresponding type declarations.ts(2307)

Note: if you choose to install router when configuring create-vue, App.vue will already use the absolute path syntax and have an error.

Extra info

  • I use Visual Studio Code + Volar extension for other vue 3 vue cli TypeScript projects and don't have the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions