angular - 目标入口点中的错误缺少依赖项:对于子组件
问题描述
我有一个带有子组件 child-x 和 child-y 的 angular 8 库 lib-a。
在使用 angular 9 项目中的 lib-a 时,出现如下构建错误:
**目标入口点“@abc/lib-a”中的错误缺少依赖项:
- ./lib-a/child-x/child-x.component
- ./lib-a/child-y/child-y.component**
ng-package.json 是,
{
"$schema": "../../node_modules/ng-package/ng-package.schema.json",
"dest": "../../dist/lib-a",
"lib": {
"entryFile": "src/public-api.ts"
}
}
lib-a 的 package.json 是:
{
"name": "lib-a",
"version": "1.0.6",
"description": "lib a",
"peerDependencies": {
"@angular/common": "^8.0.0",
"@angular/core": "^8.0.0",
"@angular/elements": "^9.1.6",
"@angular/cdk": "^8.2.3"
}
}
编辑:public-api.ts
export * from './lib-a/lib-a.module';
export * from './lib-a/child-x/child-x.component';
export * from './lib-a/child-y/child-y.component';
我尝试通过在 public-api.ts 入口点添加组件来修复,但这不起作用。
我搜索了网络,但没有找到与此子组件相关的问题的答案。
解决方案
这个问题突然出现在我面前,我能够解决它。我的项目文件夹中有一个角度库和应用程序。我正在玩弄使用引用库的导入,而不是组件的绝对路径,即import {mycomponent} from 'my-library'
而不是 import {mycomponent} from 'projects/src/lib/<etc>'
. 指向 dist 文件夹的代码挥之不去。一旦我删除了 dist 文件夹,就会显示真正的错误(这些引用)。一旦我修复了这些错误,问题就解决了。
推荐阅读
- python - 我似乎无法在没有错误的情况下在 django 中使用 DateTimeField
- android - 找不到明确的活动类 {...}; 您是否在 AndroidManifest.xml 中声明了此活动?
- javascript - React-Redux - TypeError:state.menu 不可迭代
- typescript - Typescript - 为什么没有相应地强制实现接口
- javascript - Angular-7 - 如何创建混合网络和气泡图
- r - R中两个数据集之间的近似字符串匹配
- json - Filtering with regex vs json
- php - 如何将收件人地址添加到我的联系表格
- python - Cannot convert string into float Python and code isn't producing the expected output
- indexing - 我可以基于串联字符串创建 Couchbase Lite 索引吗?