Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 6,205,675 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.