我在NPM上有一个小的angular
软件包,我一直支持在所有新版本的peerDependencies
中使用。在我的package.json中,我向 "peerDependencies": {
"@angular/animations": "^7.x",
"@angular/common": "^7.x",
"@angular/core": "^7.x",
"@angular/platform-browser": "^7.x",
"rxjs": "^6.x",
"typescript": ">=3.1.1 <3.3.0",
"zone.js": "^0.8.x"
}
列表中添加了angular,以确保它们始终存在于使用我的库的项目中:
npm install
但是随着每个主要新版本的angular的发布,我的库用户不断遇到npm WARN ng2-go-top-button@7.1.0 requires a peer of @angular/animations@^7.x but none is installed. You must install peer dependencies yourself.
时,控制台上会显示对等项不匹配警告,如下所示:
angular
所以我的问题是:在我的库中将angular
声明为依赖项的正确方法是什么,这样我就不必在每次发布新的peerDependencies
时对其进行更新?也许我根本不需要def is_specific_stuff(line):
expr = ".*(specific|work)_stuff.*"
match = re.match(expr, line)
return bool(match)
?但是如何确保使用我的库的项目始终具有所有需要的库?预先感谢。
答案 0 :(得分:0)
好,所以我自己想出了一个解决方案,因为其他问题的答案与我的问题不太吻合。
我可以使用上一个答案中建议的angular
或"*"
版本来定义"^x.x"
和其他依赖项,但这并不是很正确,因为{ {1}}与最新版本的angular
完全兼容,这就是将依赖项版本设置为typescript
可能导致依赖我的库的项目中断的原因。
因此,最后,我决定按原样保留"*"
列表,并在每次发布新的peerDependencies
时对其进行更新。这样,我的库将保留兼容的依赖关系列表,并且不会中断开发,也不会导致依赖项目中断。