browser-resolve 
node.js resolve algorithm with browser field support.
api
resolve(id, opts={}, cb)
Resolve a module path and call cb(err, path [, pkg])
Options:
filename- the calling filename where therequire()call originated (in the source)paths-require.pathsarray to use if nothing is found on the normalnode_modulesrecursive walkpackageFilter- transform the parsedpackage.jsoncontents before looking at themainfieldmodules- object with module id/name -> path mappings to consult before doing manual resolution (use to provide core modules)browser- the 'browser' property to use from package.json (defaults to 'browser')
resolve.sync(id, opts={})
Same as the async resolve, just uses sync methods.
basic usage
you can resolve files like require.resolve():
core modules
By default, core modules (http, dgram, etc) will return their same name as the path. If you want to have specific paths returned, specify a modules property in the options object.
browser field
browser-specific versions of modules
skip
You can skip over dependencies by setting a browser field value to false:
This is handy if you have code like:
so that require('tar') will just return {} in the browser because you don't intend to support the .parse() export in a browser environment.
license
MIT
upgrade notes
Prior to v1.x this library provided shims for node core modules. These have since been removed. If you want to have alternative core modules provided, use the modules option when calling resolve.
This was done to allow package managers to choose which shims they want to use without browser-resolve being the central point of update.