🚀 Socket Launch Week 🚀 Day 4: Introducing Historical Analytics.Learn More
Socket
Sign inDemoInstall
Socket

module-resolver

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

module-resolver

Asynchronous require.resolve() implementation

1.0.0
latest
npm
Version published
Maintainers
1
Created
Source

Node Module Resolver

Asynchronous implementation of the node require.resolve() algorithm except you can pass in the file to compute paths relatively to along with your own require.paths without updating the global copy (which doesn't even work in node >=0.5).

methods

var resolve = require('node-module-resolver');

resolve.async(pkg, opts, callback)

Asynchronously search for the package/filename string pkg according to the require.resolve() algorithm for X=pkg and Y=opts.basedir. Callback is fired with the located module or without arguments if nothing is found.

Default values for opts

{
    paths : [],
    basedir : __dirname,
    extensions : [ '.js' ],
    readFileSync : fs.readFileSync,
    isFile : function (file) {
        return path.existSync(file) && fs.statSync(file).isFile()
    }
}

Optionally you can specify a opts.packageFilter function to map the contents of JSON.parse()'d package.json files.

If nothing is found, all of the directories in opts.paths are searched.

resolve.isCore(pkg)

Return whether a package is in core.

Thanks

To the Node team for documenting what their mad-cap system is, and James Halliday for the synchronous implementation Node-Module-Resolver is forked from.

Keywords

resolve

FAQs

Package last updated on 05 Feb 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts