在angular 6项目中,我使用angular cli命令ng g lierary @some/libName创建了angular库。在我的库中,我有一个需要@ng-bootstrap/ng-bootstrap的组件,所以我通过npm i --save @ng-bootstrap/ng-bootstrap添加了它。
当我尝试使用ng build @some/libName --prod命令构建这个库时,它抛出了下面的错误。
Dependency @ng-bootstrap/ng-bootstrap must be explicitly whiteliste有人解决了吗?
发布于 2018-05-19 22:17:59
更新
此警告来自ng-packagr (and there's now a section of the ng-packagr docs about this)。事实证明,ng-packagr只是告诉您,它希望您将所有依赖项添加到ng-package.json中的"allowedNonPeerDependencies": []属性(此选项过去称为"whitelistedNonPeerDependencies")。例如:
{
"allowedNonPeerDependencies": [
"tslib",
...
]
}原创
我自己也遇到了这个。我认为这个警告来自ng-packagr ( angular-cli依赖它来生成和打包库)。我不太确定他们所说的“白名单”是什么意思,因为在ng-packagr的文档中似乎没有直接解释这种说法,但是this issue in the ng-packagr repo有很多不同的方法来解决这个问题。
The github issue有更多关于这方面的信息。
发布于 2018-12-05 17:05:32
在ng-package.json中添加了这个,它对我很有效
{
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
"lib": {
"entryFile": "public_api.ts"
},
"whitelistedNonPeerDependencies": [
"."
]
}https://stackoverflow.com/questions/50306714
复制相似问题