gpt4 book ai didi

node.js - 如何安装最新版本的 npm 包

转载 作者:行者123 更新时间:2023-12-01 12:43:50 35 4
gpt4 key购买 nike

如何安装 npm 包的最新可用版本? '@latest' 肯定不会获取最新的 - 我认为这意味着最新的稳定版或其他东西。

我一直在使用 hack 一段时间,因为我似乎找不到任何关于此的信息:

npm i extract-text-webpack-plugin@X 

“X”导致它失败并转储所有可能的版本,然后我复制并粘贴正确的版本而不是“X”。有点可笑。

我已经尝试过诸如“最新版本”之类的 3rd 方软件包,但它们都无法获得最新版本。

似乎没有官方这样做。例如在撰写本文时,extract-text-webpack-plugin 的最新版本是 2.0.0-beta.4。但是这样做:
npm i extract-text-webpack-plugin@latest

将安装“1.0.1”

我可以通过执行查看最新版本
npm info pkg versions --json (without --json it will cut off when there are many versions)

由于缺乏实际工具,我想这将是一些 grep 工作。

最佳答案

版本 1.0.1 是该软件包的“最新”版本 - 至少发布到 npm 注册表( taggedlatest )
来自 cli/dist-tag 的文档.强调我的。

Tags can be used to provide an alias instead of version numbers.

For example, a project might choose to have multiple streams of development and use a different tag for each stream, e.g., stable, beta, dev, canary.

By default, the latest tag is used by npm to identify the current version of a package, and npm install (without any @ or @ specifier) installs the latest tag. Typically, projects only use the latest tag for stable release versions, and use other tags for unstable versions such as prereleases.

By default, other than latest, no tag has any special significance to npm itself.


如果您想要 beta releases ,然后从 GitHub 安装,或明确使用标签。
$ npm install webpack/extract-text-webpack-plugin
这一点由 reading the manual. 说得很清楚
更清楚的是: latest是一个隐式标签,附加到 的包的任何已发布版本上。不是 使用显式标签 ( --tag ) 发布。
安装 xyz@latest只需查找标记为 latest 的版本即可在注册表中。对于这个包,就是版本 1.0.1 . 就是这样 .这里没有什么特别的。 @latest不提取发布到 npm 的最新版本
列为测试版的版本标记不同。显然他们都没有被标记为 latest ,所以尝试使用 @latest得到一个是没有意义的。
从注册表:
'dist-tags': { latest: '1.0.1', beta: '2.0.0-beta.4' }
同样,使用 GitHub 版本获取前沿信息,或明确使用版本/标签。
$ npm install extract-text-webpack-plugin@beta
给你,专为你打造:
  • recent-version
  • recent-version-cli

  • 把它压缩成一个 shell 脚本,你就可以开始了:
    $ npm install extract-text-webpack-plugin@$(recent-version extract-text-webpack-plugin)

    关于node.js - 如何安装最新版本的 npm 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39650856/

    35 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com