Require a module like `require()` but from a given path
$ cnpm install req-from
Require a module like
require()but from a given path
$ npm install --save req-from
const reqFrom = require('req-from');
// There is a file at `./foo/bar.js`
reqFrom('foo', './bar');
Like require(), throws when the module can't be found.
Returns null instead of throwing when the module can't be found.
Type: string
Directory to require from.
Type: string
What you would use in require().
Create a partial using a bound function if you want to require from the same fromDir multiple times:
const reqFromFoo = reqFrom.bind(null, 'foo');
reqFromFoo('./bar');
reqFromFoo('./baz');
MIT © Sindre Sorhus
Copyright 2013 - present © cnpmjs.org | Home |