简体   繁体   English

获取主要版本 NPM Package

[英]Get major versions NPM Package

I am trying to get a list of all major version released of any particular NPM package .我正在尝试获取任何特定NPM package发布的所有主要版本的列表。

I can find the versions including the major and the experimental version list by using the following API https://registry.npmjs.org/<pkg_name>我可以使用以下 API https://registry.npmjs.org/<pkg_name>找到包括主要版本和实验版本列表的版本

But can not distinguish from the major versions from the experimental or non major versions of the package.但不能从package的实验或非主要版本区分主要版本。 I am wondering how can I do that.我想知道我该怎么做。

I have tried using a regex but it doesnt help.我试过使用正则表达式,但没有帮助。

Here is my code这是我的代码

const data = axios.get(`https://registry.npmjs.org/${packageName}`)

const regex = /(\d*)+[.]+(\d*)+[.]+(\d*)/g;
let versions: {}[] = [];

Object.keys(response.data).forEach((data: any) => {
    if (data.match(regex)) {
        versions.push(versionData);
    }
});

you can use npm programatically (nodejs code), but here is a command line reference for you.您可以以编程方式使用 npm(nodejs 代码),但这里有一个命令行参考。

you might use npm-view to get what you are after.你可以使用npm-view来获得你想要的东西。 for instance:例如:

$ npm view jest --json | jq '."dist-tags"'
{
  "latest": "26.4.0",
  "test": "21.3.0-beta.15",
  "beta": "24.2.0-alpha.0",
  "next": "26.0.1-alpha.0",
  "canary": "25.2.1-alpha.2"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在npm中加载包的多个版本 - Load multiple versions of a package in npm npm:安装并使用不同版本的软件包 - npm: install and use different versions of a package 网站在本地工作/不在Openshift上运行(将本地,全局npm软件包版本与服务器,全局npm软件包版本同步) - Site works locally / Not on Openshift (syncing local, global npm package versions with server, global npm package versions) 同时测试两个不同的 npm 包版本 - Test two different npm package versions at the same time 不同的包锁定来自不同的npm版本 - Different package-lock results from different npm versions 防止多个版本的 React(同时创建 npm 包) - Prevent multiple versions of React (while creating npm package) 使您的 NPM 包支持多个版本的对等依赖 - Make your NPM package support multiple versions of peer depedency YARN/NPM: 安装 package 版本兼容某些依赖版本 - YARN/NPM: installing package versions that are compatible to certain dependency version 如果我更改节点版本并安装 npm ,package-lock.json 中的 package 版本是否更改? - If I change the node version and do npm install, does the package versions in package-lock.json change? 获取没有入口点的 NPM package 的路径 - Get a path to NPM package without entry point
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM