【问题标题】:Using ng-packagr it doesnt recognise my tsconfig paths使用 ng-packagr 它无法识别我的 tsconfig 路径
【发布时间】: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


【解决方案1】:

这已经是 ng-packagr 存储库中报告的问题,您可以将 tsconfig 配置复制到 ng-packagr 配置文件,因为 ng-packagr 不会从您的 tsconfig 读取,但它在 tgzing(构建)时具有其特定配置。

您可以在此处查看他们的 repo 线程中的问题:

https://github.com/dherges/ng-packagr/issues/519

【讨论】:

    猜你喜欢
    • 2019-07-20
    • 2023-03-18
    • 2020-09-08
    • 2020-01-27
    • 2019-02-15
    • 2019-05-25
    • 2019-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多