Skip to content

Semver:https://semver.org/lang/zh-CN/

参考

https://juejin.cn/post/6956532675473571876

使用nodejs 获取 npm 官方平台 包最新版本

javascript
async function getLatestVersion(id, range = '') {
  const registry = 'https://registry.npmmirror.com'
  return axios.get(`${registry}/${encodeURIComponent(id).replace(/^%40/, '@')}/${range}`)
}

const res = await getLatestVersion('axios', 'latest')
console.log(res.data.version)