req-cwd
Require a module like
require()
but from the current working directory
Install
$ npm install --save req-cwd
Usage
const reqCwd = ; // Target module is at '/Users/sindresorhus/unicorn/foo.js' console;//=> '/Users/sindresorhus/rainbow' console;//=> '/Users/sindresorhus/unicorn' const foo = ;
API
reqCwd(moduleId)
Like require()
, throws when the module can't be found.
reqCwd.silent(moduleId)
Returns null
instead of throwing when the module can't be found.
moduleId
Type: string
What you would use in require()
.
Related
- req-from - Require a module from a given path
- resolve-from - Resolve the path of a module from a given path
- resolve-cwd - Resolve the path of a module from the current working directory
- resolve-pkg - Resolve the path of a package regardless of it having an entry point
- lazy-req - Require modules lazily
License
MIT © Sindre Sorhus