Security News
Internet Archive Hacked, 31 Million Record Compromised
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
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
import latestVersion from 'latest-version';
console.log(await latestVersion('ava'));
//=> '6.1.1'
console.log(await latestVersion('@sindresorhus/df'));
//=> '4.0.0'
// Also works with semver ranges and dist-tags
console.log(await latestVersion('npm', {version: 'latest-5'}));
//=> '5.10.0'
This package exposes the version
, registryUrl
, and omitDeprecated
options from package-json
, as well as the PackageNotFoundError
and VersionNotFoundError
errors.
FAQs
Get the latest version of an npm package
The npm package latest-version receives a total of 5,870,059 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.
Security News
The Internet Archive's "Wayback Machine" has been hacked and defaced, with 31 millions records compromised.
Security News
TC39 is meeting in Tokyo this week and they have approved nearly a dozen proposals to advance to the next stages.
Security News
Our threat research team breaks down two malicious npm packages designed to exploit developer trust, steal your data, and destroy data on your machine.