npm install with ^ dependency instead of exact match

百般思念 提交于 2019-12-24 19:27:30

问题


I am developing an npm package and realized that it is added with the exact version to the package.json when adding it with

npm i -S packagename

How can I tell it to use ^0.0.1 instead of 0.0.1 ? Can I define this as the default from within the package itself?


回答1:


That happens because ^0.0.1 is considered to be equivalent to 0.0.1.

When the version of a package starts with 0 it's considered to be in development, and the semantic versioning rules are different. An increase in either of the numbers can be expected to have breaking changes when the version is 0.0.X. You can see the rules here.

Caret Ranges ^1.2.3 ^0.2.5 ^0.0.4

Allows changes that do not modify the left-most non-zero digit in the [major, minor, patch] tuple. In other words, this allows patch and minor updates for versions 1.0.0 and above, patch updates for versions 0.X >=0.1.0, and no updates for versions 0.0.X.

You'll probably see the caret when you increment the minor version, but it will also have the special rules that are mentioned over. "Normal" rules start applying when you increment the major version.



来源:https://stackoverflow.com/questions/47848064/npm-install-with-dependency-instead-of-exact-match

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!