npm 安装带有 ^ 依赖项而不是完全匹配
npm install with ^ dependency instead of exact match
我正在开发一个 npm 包,并意识到在使用
添加时,它被添加到 package.json 中
npm i -S packagename
如何告诉它使用 ^0.0.1 而不是 0.0.1 ?
我可以将其定义为包本身的默认设置吗?
发生这种情况是因为 ^0.0.1
被认为等同于 0.0.1
。
当包的版本以 0 开头时,它被认为是在开发中,并且语义版本控制规则不同。当版本为 0.0.X
时,预计任何一个数字的增加都会产生重大变化。可以看到规则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
.
当您增加次要版本时,您可能会看到插入符号,但它也会有上面提到的特殊规则。当您增加主要版本时,“正常”规则开始应用。
我正在开发一个 npm 包,并意识到在使用
添加时,它被添加到 package.json 中npm i -S packagename
如何告诉它使用 ^0.0.1 而不是 0.0.1 ? 我可以将其定义为包本身的默认设置吗?
发生这种情况是因为 ^0.0.1
被认为等同于 0.0.1
。
当包的版本以 0 开头时,它被认为是在开发中,并且语义版本控制规则不同。当版本为 0.0.X
时,预计任何一个数字的增加都会产生重大变化。可以看到规则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 versions1.0.0
and above, patch updates for versions0.X >=0.1.0
, and no updates for versions0.0.X
.
当您增加次要版本时,您可能会看到插入符号,但它也会有上面提到的特殊规则。当您增加主要版本时,“正常”规则开始应用。