finds the user's path for a module like browserify
MIT License
For a CLI module like "browserify"
or "watchify"
, resolves to the path for that module in local or global installs.
var find = require('resolve-npm-which')
find('browserify', {
basedir: process.cwd()
}, function(err, file) {
if (err) throw err
// now require it !
var browserify = require(file)
})
First it will use the resolve algorithm to look through locals, and then it will fall back to npm-which to look through globals.
The callback provides the path to the module so that it can be required.
find(name, opt, cb)
Finds the module name
with the given options (passed to resolve), then calls cb
with the error/success state.
Options must include basedir
to search for.
Note: To test, you need to have browserify
installed gobally, and npm config get prefix
should return a meaningful value.
MIT, see LICENSE.md for details.