我开始输入@Component()
,而VS Code无法正确解析导入路径。
预期结果:
import { Component } from "@angular/core";
观察结果:
import { Component } from "../../../../node_modules/@angular/core";
有人有什么错的想法吗?
更新1
tsconfig.json
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"es6",
"dom"
],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
],
"baseUrl": ".",
"paths": {
"@shared/*": [
"./shared/*"
],
"@app/*": [
"./app/*"
],
"@global/*": [
"./global/*"
]
}
}
}
答案 0 :(得分:0)
您可以使用此命令更好地了解问题所在
tsc --traceResolution | grep @shared
最有可能您的baseUrl和路径不正确匹配