【发布时间】:2020-04-11 12:27:38
【问题描述】:
我的 Angular 项目结构如下所示:
我的目标是能够将 register.component.ts 导入到 auth-routing.module.ts 中
import { RegisterComponent } from '@pages/auth/authpages/register/register.component';
为此,我添加了 tsconfig.json 的路径,如下所示:
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"typeRoots": ["node_modules/@types"],
"importHelpers": true,
"target": "es2015",
"lib": [
"es2018",
"dom"
],
"baseUrl": "src",
"paths": {
"@pages/*": ["app/pages*"]
}
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true
}
}
由于某种原因,它仍然无法正常工作。 该组件已正确导出,并且可以使用标准 ts 路径作为目标。 有谁知道问题出在哪里?
【问题讨论】:
-
你得到什么错误?你能检查一下
"baseUrl": "./src",和"@pages/*": ["./app/pages/*"]有什么不同吗?也许即使只是"@pages/*": ["app/pages/*"]也能完成这项工作 -
它只是说“无法从路径中找到模块”,建议的代码不会改变任何东西。
标签: json angular typescript path tsconfig