What is get-npm-tarball-url?
The npm package 'get-npm-tarball-url' is designed to retrieve the tarball URL of a given npm package. This is useful for various purposes such as downloading the package source code, analyzing package contents, or integrating with build systems that require direct access to npm package tarballs.
Retrieve tarball URL
This feature allows users to fetch the tarball URL for a specific version of an npm package. The function 'getTarballUrl' takes a package name and a version, then logs the URL or an error if it fails.
const getNpmTarballUrl = require('get-npm-tarball-url');
async function getTarballUrl(packageName, version) {
try {
const url = await getNpmTarballUrl(packageName, version);
console.log('Tarball URL:', url);
} catch (error) {
console.error('Error fetching tarball URL:', error);
}
}
getTarballUrl('express', '4.17.1');