Get info about npm package
First, install the library in your project by npm:
$ npm install npm-get-package-info
Or Yarn:
$ yarn add npm-get-package-info
Connect the library to the project with ES6 import:
import npmGetPackageInfo from 'npm-get-package-info';
Or CommonJS:
const npmGetPackageInfo = require('npm-get-package-info');
Next use library:
const info = await npmGetPackageInfo({
// options...
});
Name | Type | Default | Description | Available options |
---|---|---|---|---|
name | string | undefined |
Package name | e.g.: react |
version | string | undefined |
Package version | e.g.: 16.8.0 , ~2.1.2 , ^4.5.0 |
parseOutput | boolean | true |
Parse results to JSON | Enable true / disable false |
info | string[] or string | package.json fields keys | Info about packages to be fetched | e.g.: version , contributors , main etc. |
Info for latest React version:
await npmGetPackageInfo({
name: 'react',
});
Not parsed license and description for latest jQuery version:
await npmGetPackageInfo({
name: 'jquery',
parseOutput: false,
info: ['license', 'description'],
});
Description for Angular v9.0.0:
await npmGetPackageInfo({
name: 'angular',
version: '9.0.0',
info: 'description',
});
This project is licensed under the MIT License ยฉ 2020-present Jakub Biesiada