node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »


npm-pick-manifest npm version license Travis AppVeyor Coverage Status

npm-pick-manifest is a standalone implementation of npm's semver range resolution algorithm.


$ npm install --save npm-pick-manifest

Table of Contents


const pickManifest = require('npm-pick-manifest')
fetch('').then(res => {
  return res.json()
}).then(packument => {
  return pickManifest(packument, '^1.0.0')
}) // get same manifest as npm would get if you `npm i npm-pick-manifest@^1.0.0`


  • Uses npm's exact semver resolution algorithm
  • Supports ranges, tags, and versions


The npm-pick-manifest team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.


> pickManifest(packument, selector, [opts]) -> manifest

Returns the manifest that matches selector, or throws an error.

Packuments are anything returned by metadata URLs from the npm registry. That is, they're objects with the following shape (only fields used by npm-pick-manifest included):

  name: 'some-package',
  'dist-tags': {
    foo: '1.0.1'
  versions: {
    '1.0.0': { version: '1.0.0' },
    '1.0.1': { version: '1.0.1' },
    '1.0.2': { version: '1.0.2' },
    '2.0.0': { version: '2.0.0' }

The algorithm will follow npm's algorithm for semver resolution, and only tag, range, and version selectors are supported.

The function will throw ETARGET if there was no matching manifest, and ENOVERSIONS if the packument object has no valid versions in versions.

If opts.defaultTag is provided, it will be used instead of latest. That is, if that tag matches the selector, it will be used, even if a higher available version matches the range.