简体   繁体   English

在 package.json 中为该包内的包安装特定版本的依赖项

[英]Installing specific version of dependencies for a package inside that package in package.json

I know the title is confusing but I wasn't sure how to word my issue...我知道标题令人困惑,但我不知道如何表达我的问题...

I am using a package in my App called "react-dnd-html5-backend".我在我的应用程序中使用了一个名为“react-dnd-html5-backend”的包。 This specific package has a dependency called "autobind-decorator".这个特定的包有一个名为“autobind-decorator”的依赖项。 autobind-decorator recently posted an update to their package that introduced conflicts in a few spots in my App. autobind-decorator 最近发布了他们包的更新,在我的应用程序中的几个地方引入了冲突。 I would like to specify that "react-dnd-html5-backend" use the exact version that I know is compatible wit my code.我想指定“react-dnd-html5-backend”使用我知道与我的代码兼容的确切版本。 Is there a way to specify that in my package.json file?有没有办法在我的 package.json 文件中指定它? To specify the version of "autobind-decorator" that "react-dnd-html5-backend" uses while in my application?要指定“react-dnd-html5-backend”在我的应用程序中使用的“autobind-decorator”版本?

Adding autobind-decorator with a specific version as a dependency into your project's package.json will force to install that version.将具有特定版本的autobind-decorator作为依赖项添加到项目的package.json中将强制安装该版本。

Note that react-dnd-html5-backend should support to use autobind-decorator version, if not it will cause a version conflict error.注意react-dnd-html5-backend应该支持使用autobind-decorator版本,否则会导致版本冲突错误。

Thanks Gonzalo!谢谢贡萨洛! I believe I tried that but was unable to override the version used by "react-dnd-html5-backend" In my impatience I actually found a different solution that I figured I should post in case anyone else runs into the same problem.我相信我尝试过,但无法覆盖“react-dnd-html5-backend”使用的版本在我的不耐烦中,我实际上找到了一个不同的解决方案,我认为我应该发布,以防其他人遇到同样的问题。 It looks like you can specify the version of a nested package by using the resolutions field of the package.json:看起来您可以使用 package.json 的分辨率字段来指定嵌套包的版本:

https://github.com/yarnpkg/rfcs/pull/68/files https://github.com/yarnpkg/rfcs/pull/68/files

Example:
"resolutions": {
    "**/autobind-decorator": "2.1.0"
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM