[英]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.