JSPM

  • Created
  • Published
  • Downloads 8460886
  • Score
    100M100P100Q193573F
  • License MIT

Get the package.json of a package from the npm registry

Package Exports

  • package-json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (package-json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

package-json Build Status

Get the package.json of a package from the npm registry

Install

$ npm install --save package-json

Usage

const packageJson = require('package-json');

packageJson('pageres', 'latest').then(json => {
    console.log(json);
    //=> {name: 'pageres', ...}
});

// Also works with scoped packages
packageJson('@company/package', 'latest').then(json => {
    console.log(json);
    //=> {name: 'package', ...}
});

API

packageJson(name, [version])

You can optionally specify a version (e.g. 1.0.0) or a dist tag such as latest. If you don't specify a version you'll get the main entry containing all versions.

The version can also be in any format supported by the semver module. For example:

  • 1 - get the latest 1.x.x
  • 1.2 - get the latest 1.2.x
  • ^1.2.3 - get the latest 1.x.x but at least 1.2.3
  • ~1.2.3 - get the latest 1.2.x but at least 1.2.3

Authentication

Both public and private registries are supported, for both scoped and unscoped packages, as long as the registry uses either bearer tokens or basic authentication.

License

MIT © Sindre Sorhus