Skip to content

Vue typescript not resolve paths declared in tsconfig #10822

@javilingt

Description

@javilingt

Version
2.6.10

Steps to reproduce

The structure of my project is this:

+src

  • componentes
    First.vue
  • test
    Test.vue

In tsconfig you must declare de paths you need

"compilerOptions": {
"target": "es5",
"module": "esnext",
"strict": true,
"jsx": "preserve",
"importHelpers": true,
"moduleResolution": "node",
"experimentalDecorators": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"baseUrl": ".",
"types": [
"webpack-env"
],
"paths": {
"@/": [
"src/
"
],
"@test/": [
"src/test/
"
]
},
....
}

In App.vue I use the path to resolve the location of my component

import Vue from 'vue'
import First from '@/components/First.vue'
import Second from '@test/Second.vue'

What is expected?

The path should be used in your components and resolve the location to your components.

What is actually happening?

If I use the path @ declared in tsconfig works without problems and I can use First.vue but if I declare a new path it doesn´t resolve the reference and return the error

./src/App.vue?vue&type=script&lang=ts& (./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/ts-loader??ref--13-1!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=ts&)
Module not found: Error: Can't resolve '@test/Second.vue'

I have try differents paths but it seems only resolve the @ path that is autodeclared by Vue-cli

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