npm --save如何确定哪个版本和SemVer选项? [英] How Does npm --save Decide Which Version and SemVer Options?

查看:128
本文介绍了npm --save如何确定哪个版本和SemVer选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在计算机中键入以下内容

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屋!

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