Reputation: 59355
Looking for a way to access the latest version number of an npm package. Is there some kind of API where I can't ping npm directly? Or is there a programatic npm command I can use?
getNpmVersion('lodash').then(console.log) // => 4.11.1
Upvotes: 0
Views: 235
Reputation: 59355
Found a module called npm-latest
that does exactly this:
import npmLatest from 'npm-latest'
import Promise from 'bluebird'
const npmLatestAsync = Promise.promisify(npmLatest)
async function getNpmVersion (dep) {
let { name, version } = await npmLatestAsync(dep)
return { name, version}
}
Upvotes: 3