DWQA QuestionsCategory: ProgramVue typescript cannot find module
lznism asked 2 hours ago
import Header from '@/components/header.vue';

The above code report can’t find the module. It’s OK to write the relative path, but it’s not OK to configure alias in webpack

//That's OK
import Header from '../../components/header.vue';

Ask the great God to tell why?,Except inwebpackIn addition to the configurationtsconfig.jsonConfiguration in the file

"compilerOptions": {
    "baseUrl": "./",
    "paths": {
        "@": ["src/components"]
    }
}
buzzzzz replied 4 hours ago

Alias configuration

buzzzzz replied 4 hours ago

Write it in tsconfig

1 Answers
weiwei answered 4 hours ago

Except inwebpackIn addition to the configurationtsconfig.jsonConfiguration in the file

"compilerOptions": {
    "baseUrl": "./",
    "paths": {
        "@": ["src/components"]
    }
}