{"name":"require-in-the-middle","version":"8.0.1","description":"Module to hook into the Node.js require function","main":"index.js","types":"types/index.d.ts","dependencies":{"debug":"^4.3.5","module-details-from-path":"^1.0.3"},"devDependencies":{"@babel/core":"^7.9.0","@babel/preset-env":"^7.9.5","@babel/preset-typescript":"^7.9.0","@babel/register":"^7.9.0","ipp-printer":"^1.0.0","patterns":"^1.0.3","roundround":"^0.2.0","semver":"^6.3.0","standard":"^14.3.1","tape":"^4.11.0"},"scripts":{"test":"npm run test:lint && npm run test:tape && npm run test:babel","test:lint":"standard","test:tape":"tape test/*.js","test:babel":"node test/babel/babel-register.js"},"repository":{"type":"git","url":"git+https://github.com/nodejs/require-in-the-middle.git"},"keywords":["require","hook","shim","shimmer","shimming","patch","monkey","monkeypatch","module","load"],"author":{"name":"Thomas Watson Steen","email":"w@tson.dk","url":"https://twitter.com/wa7son"},"license":"MIT","bugs":{"url":"https://github.com/nodejs/require-in-the-middle/issues"},"homepage":"https://github.com/nodejs/require-in-the-middle#readme","engines":{"node":">=9.3.0 || >=8.10.0 <9.0.0"},"gitHead":"2d6cbd8f213cd51727ed6b7cee342b10b7e1456f","_id":"require-in-the-middle@8.0.1","_nodeVersion":"24.10.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-QT7FVMXfWOYFbeRBF6nu+I6tr2Tf3u0q8RIEjNob/heKY/nh7drD/k7eeMFmSQgnTtCzLDcCu/XEnpW2wk4xCQ==","shasum":"dbde2587f669398626d56b20c868ab87bf01cce4","tarball":"http://registry-npm.ywwl.com/require-in-the-middle/download/require-in-the-middle-8.0.1.tgz","fileCount":5,"unpackedSize":18280,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/require-in-the-middle@8.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBRQ7koXEn66eUuaMIWLxd2+Ap5ehKgL+tQXFR46IEjvAiACyU3ovvuATx/n8zVkFAqfuEvTlQLOi2JH+XpUzDvI0Q=="}],"size":6351,"noattachment":false,"key":"/require-in-the-middle/-/require-in-the-middle-8.0.1.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:cf385014-b435-4513-9f79-68b5e45a432e"}},"directories":{},"maintainers":[{"name":"trentm","email":"trentm@gmail.com"},{"name":"watson","email":"w@tson.dk"},{"name":"nodejs-foundation","email":"build@iojs.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/require-in-the-middle_8.0.1_1760963241277_0.7299184155444507"},"_hasShrinkwrap":false,"readme":"# require-in-the-middle\n\nHook into the Node.js `require` function. This allows you to modify\nmodules on-the-fly as they are being required.\n\n[![npm](https://img.shields.io/npm/v/require-in-the-middle.svg)](https://www.npmjs.com/package/require-in-the-middle)\n[![Test status](https://github.com/nodejs/require-in-the-middle/workflows/Test/badge.svg)](https://github.com/nodejs/require-in-the-middle/actions)\n\nAlso supports hooking into calls to `process.getBuiltinModule()`, which was introduced in Node.js v22.3.0.\n\n## Installation\n\n```\nnpm install require-in-the-middle --save\n```\n\n## Usage\n\n```js\nconst path = require('path')\nconst { Hook } = require('require-in-the-middle')\n\n// Hook into the express and mongodb module\nnew Hook(['express', 'mongodb'], function (exports, name, basedir) {\n  const version = require(path.join(basedir, 'package.json')).version\n\n  console.log('loading %s@%s', name, version)\n\n  // expose the module version as a property on its exports object\n  exports._version = version\n\n  // whatever you return will be returned by `require`\n  return exports\n})\n```\n\n## API\n\nThe require-in-the-middle module exposes a single function:\n\n### `hook = new Hook([modules][, options], onrequire)`\n\nWhen called a `hook` object is returned.\n\nArguments:\n\n- `modules` &lt;string[]> An optional array of module names to limit which modules\n  trigger a call of the `onrequire` callback. If specified, this must be the\n  first argument. Both regular modules (e.g. `react-dom`) and\n  sub-modules (e.g. `react-dom/server`) can be specified in the array.\n- `options` &lt;Object> An optional object containing fields that change when the\n  `onrequire` callback is called. If specified, this must be the second\n  argument.\n  - `options.internals` &lt;boolean> Specifies whether `onrequire` should be called\n    when module-internal files are loaded; defaults to `false`.\n- `onrequire` &lt;Function> The function to call when a module is required.\n\nThe `onrequire` callback will be called the first time a module is\nrequired. The function is called with three arguments:\n\n- `exports` &lt;Object> The value of the `module.exports` property that would\n  normally be exposed by the required module.\n- `name` &lt;string> The name of the module being required. If `options.internals`\n  was set to `true`, the path of module-internal files that are loaded\n  (relative to `basedir`) will be appended to the module name, separated by\n  `path.sep`.\n- `basedir` &lt;string> The directory where the module is located, or `undefined`\n  for core modules.\n\nReturn the value you want the module to expose (normally the `exports`\nargument).\n\n### `hook.unhook()`\n\nRemoves the `onrequire` callback so that it will not be triggerd by\nsubsequent calls to `require()` or `process.getBuiltinModule()`.\n\n## License\n\n[MIT](https://github.com/nodejs/require-in-the-middle/blob/master/LICENSE)\n","publish_time":1760963241478,"_cnpm_publish_time":1760963241478,"dist-tags":{"latest":"8.0.1"}}