snoops npm dependencies in a JavaScript bundle
Last updated 5 years ago by mattdesl .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install snoop-bundle-deps 
SYNC missed versions from official npm registry.



Finds all npm modules used by a browserify bundle.

var snoop = require('snoop-bundle-deps')
var fs = require('fs')

var bundle = fs.readFileSync(__dirname+'/bundle.js')

//get an array of public npm dependencies used in bundle
snoop(bundle, function(err, deps) {
  if (err) throw err
  // -> ['eases', 'object-assign', 'url', 'xtend']

Ignores relative requires, de-duplicates paths like "xtend/mutable.js" to their base packages, and filters out any modules that cannot be found on npm. Uses a cache to avoid querying the database for popular module names.

Can also be used via CLI:

snoop-bundle-deps -p < my-svg-app.js
dependencies [5]
├── abs-svg-path
├── adaptive-bezier-curve
├── normalize-svg-path
├── svg-path-contours
└── vec2-copy




snoop(src, [opt], callback)

Snoops the src bundle. Options are passed to filter-npm-modules, but using a default cache to avoid common DB queries.

Calls the function with (err, deps) where deps is an array of sorted and de-duplicated npm package names.


The CLI takes a bundle in stdin and writes JSON array to stdout. Or, you can pretty-print with shell pipes.

  snoop-bundle-deps [opts] < bundle.js

  --pretty, -p   pretty-print the results

in the wild

This could even be used for minified bundles in the wild. For example, as of April 2015, Yahoo Play is using roughly 77 public npm modules in its primary bundle.

curl | snoop-bundle-deps -p
dependencies [77]
├── asn1.js
├── asn1.js-rfc3280
├── async-cache
├── base64-js
├── blast-text
├── bn.js
├── brorand
├── browserify-aes
├── browserify-rsa

(full list)

This will not work on modules compressed with bundle-collapser.



MIT, see for details.

Current Tags

  • 1.0.2                                ...           latest (5 years ago)

3 Versions

  • 1.0.2                                ...           5 years ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (8)
Dev Dependencies (1)

Copyright 2014 - 2017 © |