Skip to content

Require another package in Node.js if your first choice doesn't exist.

License

Notifications You must be signed in to change notification settings

fabiandev/node-require-fallback

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-require-fallback

Require another package in Node.js if your first choice doesn't exist.

Useful for development, where you want to use a local copy of your package, but it shouldn't break the application for your team, which is depending on a npm package.

Installation

npm install --save node-require-fallback

Node.js >= 6 is required for this package.

Example Usage

var requireIfExists = require('node-require-fallback');

var myModule = requireIfExists('./module1', 'module2', 'module3');

You can pass as many modules to requireIfExists as you want. The first one that can be found will be loaded, otherwise null will be returned.

About

Require another package in Node.js if your first choice doesn't exist.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published