使用^依赖性而不是完全匹配的npm安装 [英] npm install with ^ dependency instead of exact match

查看:168
本文介绍了使用^依赖性而不是完全匹配的npm安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个npm软件包,并意识到当使用以下命令添加该软件包时,它将与确切版本一起添加到package.json中

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

如何告诉它使用^ 0.0.1而不是0.0 .1吗?
我可以在软件包本身中将其定义为默认值吗?

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?

推荐答案

发生这种情况是因为 ^ 0.0.1 被认为等效于 0.0.1

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

包以0开头,被认为是正在开发中,语义版本控制规则也不同。当版本为 0.0.X 时,这两个数字的增加都可能会有重大变化。您可以在此处看到规则。

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

允许更改不要修改[major,minor,patch]元组中最左边的非零数字。换句话说,这允许对1.0.0及更高版本的补丁程序和次要更新,对于0.X> = 0.1.0版本的补丁程序更新,以及对于0.0.X版本的更新程序。

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.

这篇关于使用^依赖性而不是完全匹配的npm安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆