Skip to content

Implements the node.js require.resolve() algorithm

License

Notifications You must be signed in to change notification settings

isaacs/node-resolve

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

resolve

Implements 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).

build status

methods

var resolve = require('resolve');

resolve.sync(pkg, opts)

Synchronously search for the package/filename string pkg according to the require.resolve() algorithm for X=pkg and Y=opts.basedir.

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.

About

Implements the node.js require.resolve() algorithm

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published