简体   繁体   English

如何更新到模块上特定版本的子依赖项

[英]how can I update to specific version of child dependency on a module

npm version: 7.24.2 npm 版本:7.24.2

someone know update a child dependency, I have the dependency:有人知道更新子依赖项,我有依赖项:

  • vue-tel-input Vue 电话输入

and this dependency has the dependency libphonenumber-js with version: ^1.9.6并且此依赖项具有依赖 libphonenumber-js 版本:^1.9.6

I want to update this libphonenumber-js to ^1.10.12 I already tried with:我想将此 libphonenumber-js 更新为 ^1.10.12 我已经尝试过:

any idea?任何想法?

I don't think you can do that easily with your current setup.我认为您无法使用当前设置轻松做到这一点。

you can either update to npm v8.3 +, which supports overrides or use yarn with resolutions您可以更新到npm v8.3 +,它支持overrides或使用具有resolutionsyarn

more info:更多信息:

overrides(npm): https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides覆盖(npm): https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides

package.json package.json

  "overrides": {
    "vue-tel-input": {
      "libphonenumber-js": "^1.10.12"
    }
  }

resolutions(yarn): https://classic.yarnpkg.com/en/docs/selective-version-resolutions/分辨率(纱线): https://classic.yarnpkg.com/en/docs/selective-version-resolutions/

package.json package.json

  "resolutions": {
    "libphonenumber-js": "^1.10.12"
  }

alternatively, you can manage the package-lock.json file manually to define the version或者,您可以手动管理package-lock.json文件以定义版本

"vue-tel-input": {
  "version": "5.11.0",
  "resolved": "https://registry.npmjs.org/vue-tel-input/-/vue-tel-input-5.11.0.tgz",
  "integrity": "sha512-kw13LdbnSH+Zk5Qb06vflG7Abu6QsM1cQyKvTA9T4kaZeARvyvKo9YZmziy7WiSuar932DWRjGI0SJnban4a2A==",
  "requires": {
    "core-js": "^3.14.0",
    "libphonenumber-js": "^1.9.6",
    "vue": "^2.6.14"
  }
},

you might be able to change "libphonenumber-js": "^1.9.6" to use ^1.10.12您也许可以更改"libphonenumber-js": "^1.9.6"以使用^1.10.12

but wanted to point out that when I did a fresh install, it did install 1.10.12但想指出的是,当我进行全新安装时,它确实安装1.10.12

"node_modules/libphonenumber-js": {
  "version": "1.10.12",
  "resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.10.12.tgz",
  "integrity": "sha512-xTFBs3ipFQNmjCUkDj6ZzRJvs97IyazFHBKWtrQrLiYs0Zk0GANob1hkMRlQUQXbJrpQGwnI+/yU4oyD4ohvpw=="
},

Because ^ will update to the latest minor version (2nd number), it should use a specific version, so in this case, because you're going from 1.9.* to 1.10.* and using ^1.9.6 you may be able to just remove your lock file and re-install to get 1.10.12因为^将更新到最新的次要版本(第二个数字),它应该使用特定的版本,所以在这种情况下,因为你要从1.9.*1.10.*并使用^1.9.6你可能能够只需删除您的锁定文件并重新安装即可获得1.10.12

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

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