【发布时间】:2018-11-20 19:10:32
【问题描述】:
对我的 Angular 6 和 AngularCLI 应用程序使用 ng-packagr,但它无法识别我的 tsconfig 路径,而我进行了构建。正常的 ng build --aot --prod 工作正常。
这些是我的路径:
"paths": {
"@app/*": ["src/app/*"],
"@env/*": ["src/environments/*"]
}
我的 tsconfig.json:
{
"compileOnSave": true,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"noImplicitAny": false,
"noImplicitReturns": true,
"noUnusedLocals": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
],
"paths": {
"@app/*": ["src/app/*"],
"@env/*": ["src/environments/*"]
}
}
}
我得到的错误往往是找不到模块....例如因为它不知道@app 是什么。
该应用在投放时也能正常工作,例如npm 开始。
【问题讨论】:
-
FWIW,我的“app”目录在“src”中,所以我将
paths指定为:"@app/environments/*": ["environments/*"]
标签: angular typescript webpack tsconfig ng-packagr