How can i get the latest version (including the pre-releases) from an array of versions using node/semver.
For example:
var semver = require("semver");
var versions = ["1.0.0-rc.10","1.0.0-rc.11"];
console.log(semver.maxSatisfying(versions, "*"));
Returns null, but i want to get the 1.0.0-rc.11 back.
Kind Regards and have a nice day!
You need to add the includePrerelease option to your maxSatisfying method as described here: https://github.com/npm/node-semver#functions
In your example:
var semver = require("semver");
var versions = ["1.0.0-rc.10","1.0.0-rc.11"];
console.log(semver.maxSatisfying(versions, "*", {
includePrerelease: true
}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With