https://github.com/fabiandev/node-require-fallback
Require another package in Node.js if your first choice doesn't exist.
https://github.com/fabiandev/node-require-fallback
node require
Last synced: about 20 hours ago
JSON representation
Require another package in Node.js if your first choice doesn't exist.
- Host: GitHub
- URL: https://github.com/fabiandev/node-require-fallback
- Owner: fabiandev
- License: mit
- Created: 2016-05-29T08:07:10.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-07T10:55:04.000Z (over 9 years ago)
- Last Synced: 2025-09-25T23:23:59.613Z (9 months ago)
- Topics: node, require
- Language: JavaScript
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```bash
npm install --save node-require-fallback
```
> Node.js >= 6 is required for this package.
# Example Usage
```javascript
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.