You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular库ngx-qwe构建时如何跳过解析依赖包ngx-asd?

解决Angular库构建时跳过指定依赖解析的方法

针对你用ng build ngx-qwe --configuration production构建库时,依赖ngx-asd出现构建错误的问题,结合你使用的Angular 9及ng-packagr 9版本,可以通过以下两种配置实现跳过该依赖的解析:

1. 跳过第三方库类型检查

打开ngx-qwe库根目录下的tsconfig.lib.json文件,在compilerOptions节点中添加"skipLibCheck": true:

{
  "compilerOptions": {
    // 其他原有配置
    "skipLibCheck": true
  }
}

这个配置会让TypeScript跳过所有第三方依赖的类型检查,避免因ngx-asd的类型定义问题导致构建失败。

2. 将ngx-asd标记为外部依赖

在库的ng-package.json文件中,添加externalDependencies配置,指定ngx-asd为外部依赖,这样ng-packagr构建时不会尝试解析打包该依赖:

{
  "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
  "dest": "../../dist/ngx-qwe",
  "lib": {
    "entryFile": "src/public-api.ts"
  },
  "externalDependencies": ["ngx-asd"]
}

完成以上配置后,重新执行构建命令ng build ngx-qwe --configuration production即可。

内容的提问来源于stack exchange,提问作者Allen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 09:42:36