robert2206 8ad867f7a5 commit inicial | 8 лет назад | |
---|---|---|
.. | ||
node_modules | 8 лет назад | |
index.js | 8 лет назад | |
license | 8 лет назад | |
package.json | 8 лет назад | |
readme.md | 8 лет назад |
Get the package.json of a package from the npm registry
$ npm install --save package-json
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', ...}
});
You can optionally specify a version (e.g. 1.0.0
) or 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
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.
MIT © Sindre Sorhus