npm --save如何确定哪个版本和SemVer选项? [英] How Does npm --save Decide Which Version and SemVer Options?
问题描述
如果我在计算机中键入以下内容
If I type the following into my computer
$ echo '{}' > package.json
$ npm install pug --save
,然后查看我的package.json
,我会看到npm
为我添加了一个依赖项.
and then look at my package.json
, I'll see that npm
added a dependency for me.
#File: package.json
{
"dependencies": {
"pug": "^2.0.0-rc.1"
}
}
甜!但是-npm
如何决定获取版本2.0.0-rc.1
? npm
如何决定使用^
SemVer版本修饰符?
Sweet! However -- how does npm
decide to grab version 2.0.0-rc.1
? And how does npm
decide to use the ^
SemVer version modifier?
作为npm
的用户,我可以配置或告诉它使用其他的SemVer修饰符和/或下载其他版本吗? (包括特定版本和/或最新稳定版本")
As a user of npm
can I configure or tell it to use a different SemVer modifier and/or download a different version? (both a specific version and/or something like "latest stable")
作为npm
软件包的维护者,我可以指定npm
的默认行为应该是获取最新版本并在其中拍打^
" 之外的其他内容吗?
As an npm
package maintainer, can I specify that npm
's default behavior should be something other than "grab the latest version and slap a ^
on there"?
推荐答案
npm将最新的标签公开发布,而^
是默认标签,您可以使用save-prefix
在本地进行更改.
npm takes the latest tag publicly available and ^
is the default, you can use save-prefix
to change it locally.
要获取特定版本,请在包名称(即npm install pug@0.1.0
)后使用@version
.
在npm world中不存在作曲家的minimum-stability
之类的东西.
To a get specific version use @version
after package name i.e. npm install pug@0.1.0
.
Something like composer's minimum-stability
doesn't exist in npm world.
作为维护者,除了保持SemVer并编写良好的代码外,您无能为力
As a maintainer, you can't do anything, except keeping SemVer and writeing good code :)
但是package.json
只是一个JSON,您可以简单地对其进行修改,而无需使用任何CLI命令并定义所需的内容.
But at all package.json
is just a JSON, you can simply modify them, without using any CLI commands and define whatever you need.
这篇关于npm --save如何确定哪个版本和SemVer选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!