nodejs / nodejs/require-in-the-middle
ExportsCache.has: `__require.cache[filename];` cannot read properties of undefined
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 186
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
I'm building with TS and esbuild.
Using v7.5.2
This is used as a side effect of @opentelemetry/auto-instrumentations-node
It seems like __require.cache doesn't exist?His is bundled with esbuild for node 22
TypeError: Cannot read properties of undefined (reading '/home/douglas/programming/08_ivr/ivr3/node_modules/.pnpm/@tsoa+runtime@6.4.0/node_modules/@tsoa/runtime/dist/index.js')
at ExportsCache.has (file:///home/douglas/programming/08_ivr/ivr3/apps/ivr3-api/dist/optTelemetry.js:9999:39)
at Module.patchedRequire (file:///home/douglas/programming/08_ivr/ivr3/apps/ivr3-api/dist/optTelemetry.js:10090:26)
at Hook._require.Module.require (file:///home/douglas/programming/08_ivr/ivr3/apps/ivr3-api/dist/optTelemetry.js:10053:31)
at require (node:internal/modules/helpers:136:16)
at Object.<anonymous> (/home/douglas/programming/08_ivr/ivr3/node_modules/.pnpm/tsoa@6.4.0/node_modules/tsoa/dist/index.js:17:14)
at Module._compile (node:internal/modules/cjs/loader:1562:14)
at Object..js (node:internal/modules/cjs/loader:1699:10)
at Module.load (node:internal/modules/cjs/loader:1313:32)
at Function._load (node:internal/modules/cjs/loader:1123:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at ExportsCache.has and Module.patchedRequire, the entry points shown in the stack trace, and inspect how __require.cache is accessed when the package is bundled with esbuild. Reproduce the failure with Node 22 and a TypeScript build; done means the require hook no longer throws when __require.cache is unavailable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100