gpt4 book ai didi

Angular 8 Peer Dependencies 混淆

转载 作者:行者123 更新时间:2023-12-04 13:18:02 27 4
gpt4 key购买 nike

我正在使用 Angular 8,并且我不断收到关于 angular/compiler-cli 对等依赖项的 npm 警告。

npm WARN @angular/compiler-cli@8.1.2 requires a peer of @angular/compiler@8.1.2 but none is installed. You must install peer dependencies yourself.



但是,如果我做 npm install @angular/compiler@8.1.2 , npm 继续提示相同的消息。

@angular/compiler@^8.0.0 is installed package-json under dependencies and '@angular/compiler-cli@^8.1.2 and @angular/compiler@^8.1.2 are installed under devDependencies.



这对我来说没有任何意义。

有谁知道如何生成将提供更多信息的错误消息?

或者至少如何解决这种类型的 npm 不一致问题?

最佳答案

dependencies 之后或之前在 package.json 中添加以下内容:

"peerDependencies": {
"@angular/compiler": "^8.1.2"
}

在那之后运行: npm install .

对等依赖项如何解决此问题
他们告诉 npm

I need this package, but I need the version that is part of the project, not some version private to my module.



当 npm 发现您的包被安装到没有该依赖项或版本不兼容的项目中时,它会在安装过程中警告用户。

什么时候应该使用对等依赖?
  • 当你正在构建一个供其他项目使用的库时,以及
  • 这个库正在使用其他一些库,和
  • 您希望/需要用户也使用该其他库
  • 关于Angular 8 Peer Dependencies 混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57874688/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com