Skip to content

Repository files navigation

npm versionnpmBuild StatusJavaScript Style Guidebadgen.netlicense

acquire-module

Node.js' require function on steroids

Installation

$ npm install acquire-module

Features

  • Search for a module in multiple directories
  • Search using both absolute and relative paths
  • You can specify a module prefix as a search option

along with all the existing features of require()

Usage

constacquire=require("acquire-module");

acquire (moduleName, [options])

ParameterTypeDescription
moduleName<string>The name of the module (if present in node_modules or if paths are specified in option.paths). Can also simply include the module path to resolve.
[options]<Object>Additional search options for moduleName.
[options.paths]<string> , <Array>.stringPaths to one or more directories to resolve module location from. For each path specified, both the path itself and node_modules will be searched.
[options.prefix]<string>Prefix of the given moduleName.

• returns a module Object

Examples

>constinquirer=acquire('inquirer')>var_=acquire('/core',{prefix: 'lodash'})>constmyModule=acquire('some-file.js',{paths: '.'})>constanotherModule=acquire('file.js',{paths: './some/place/where/file/exists',prefix: 'some'})>constnextModule=acquire('app.js',{paths: ['.','~/my-modules']})>constdoesSomething=acquire('something.js',{paths: ['some/place/unsure/where/file/is','~/my-modules','.']})

© 2019 Abir Bhushan <bhushan.abir@gmail.com>.

© 2017-19 Lloyd Brookes <75pound@gmail.com>.

About

🧪 Node's require on steroids

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Used by

Contributors

Languages