
Product
Redesigned Repositories Page: A Faster Way to Prioritize Security Risk
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
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
FAQs
Require a module like `require()` but from a given path
We found that req-from demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Our redesigned Repositories page adds alert severity, filtering, and tabs for faster triage and clearer insights across all your projects.
Security News
Slopsquatting is a new supply chain threat where AI-assisted code generators recommend hallucinated packages that attackers register and weaponize.
Security News
Multiple deserialization flaws in PyTorch Lightning could allow remote code execution when loading untrusted model files, affecting versions up to 2.4.0.