Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
require-like
Advanced tools
Generates require functions that act as if they were operating in a given path.
Generates require functions that act as if they were operating in a given path.
npm install require-like
A require function that acts as if it was executed in './lib/bar'
:
var requireLike = require('require-like');
var myRequire = requireLike(__dirname + '/lib/bar.js');
var myFoo = myRequire('./foo.js');
var foo = require('./lib/foo');
require('assert').strictEqual(myFoo, foo);
Returns a require function that acts as if it was operating in the given
path
.
Setting the uncached
parameter to true returns a function that by-passes the
module cache.
This module works by accessing some private node APIs. You shouldn't worry about that so, since I will make sure this module does not break in the future by either patching it, or making a patch for node that makes the needed APIs public.
I use this library for dependency injection in unit tests. However, you could also use it to create experimental require addons yourself.
require-like is licensed under the MIT license.
FAQs
Generates require functions that act as if they were operating in a given path.
The npm package require-like receives a total of 766,929 weekly downloads. As such, require-like popularity was classified as popular.
We found that require-like 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.