1.0.3 ā€¢ Published 3 years ago

latest-package-version v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

latest-package-version

Get latest npm package version for list of packages in a JSON object format. Note: this will give you the latest package version based on NPM registry you have configured in your operating system. If you have configured a private NPM registry then it will give you the latest version which is available in that registry.

šŸŒŸ Install

$ npm install -D latest-package-version

šŸ”Ø Usage Typescript

import { getPackageVersions } from 'latest-package-version';
(async function getVersions() {
    const { output, error } = await getPackageVersions(['react', 'vue']);
    console.log(output);
})();

šŸ”Ø Usage Javascript

const pkg = require('latest-package-version');

(async function getVersions () {
    const {output} = await pkg.getPackageVersions(['vue','@angular/core','react']);
    console.log(output);
})();

āœ”ļø It will give you result in json format like below:

{
  output: {
    '"vue"': '^2.6.12',
    '"react"': '^17.0.1',
    '"@angular/core"': '^11.2.3'
  },
  error: null
}

āœ”ļø If you passed an npm package which is not available in NPM registry then in the response you will following result.

{
  output: null,
  error: "npm ERR! 404 'reactz' is not in the npm registry.\n" +
    'npm ERR! 404 You should bug the author to publish it\n' +
    'npm ERR! 404 (or use the name yourself!)\n' +
    'npm ERR! 404 \n' +
    'npm ERR! 404 Note that you can also install from a\n' +
    'npm ERR! 404 tarball, folder, http url, or git url.\n' +
    'npm ERR! 404 \n' +
    "npm ERR! 404  'reactz@latest' is not in the npm registry.\n"
}

License

The MIT License (MIT)