Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
latest-version
Advanced tools
The 'latest-version' npm package allows you to fetch the latest version of an npm package from the npm registry. It is useful for checking if a package is up-to-date or for automating updates in your projects.
Fetch Latest Version
This feature allows you to fetch the latest version of a specified npm package. In the code sample, it fetches the latest version of the 'npm' package.
const latestVersion = require('latest-version');
(async () => {
console.log(await latestVersion('npm'));
//=> '7.24.0'
})();
Fetch Latest Version with Specific Tag
This feature allows you to fetch the latest version of a specified npm package with a specific tag. In the code sample, it fetches the latest beta version of the 'npm' package.
const latestVersion = require('latest-version');
(async () => {
console.log(await latestVersion('npm', { version: 'beta' }));
//=> '8.0.0-beta.0'
})();
The 'package-json' npm package allows you to get metadata of an npm package, including its latest version. It provides more detailed information compared to 'latest-version', such as dependencies, maintainers, and more.
The 'npm-check-updates' npm package allows you to find newer versions of dependencies than what your package.json allows. It is more focused on updating dependencies in your project rather than just fetching the latest version.
The 'semver' npm package provides utilities for working with semantic versioning. While it does not fetch the latest version from the npm registry, it can be used to compare versions and validate version strings.
Get the latest version of an npm package
Fetches the version directly from the registry instead of depending on the massive npm module like the latest module does.
$ npm install latest-version
const latestVersion = require('latest-version');
(async () => {
console.log(await latestVersion('ava'));
//=> '0.18.0'
console.log(await latestVersion('@sindresorhus/df'));
//=> '1.0.1'
// Also works with dist-tags and semver ranges
console.log(await latestVersion('npm', {version: 'latest-5'}));
//=> '5.5.1'
})();
MIT © Sindre Sorhus
FAQs
Get the latest version of an npm package
The npm package latest-version receives a total of 4,218,029 weekly downloads. As such, latest-version popularity was classified as popular.
We found that latest-version demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.