René's URL Explorer Experiment


Title: require.extensions is undefined on synthetic require for CJS loaded through ESM loader (regression in v24.15.0) · Issue #62786 · nodejs/node · GitHub

Open Graph Title: require.extensions is undefined on synthetic require for CJS loaded through ESM loader (regression in v24.15.0) · Issue #62786 · nodejs/node

X Title: require.extensions is undefined on synthetic require for CJS loaded through ESM loader (regression in v24.15.0) · Issue #62786 · nodejs/node

Description: Version v24.15.0 (fails). Works on v24.14.1 and earlier. Platform: Linux x64 (also reproduced inside node:24.15.0-slim Docker image). Platform Linux x64 Subsystem loaders, module, specifically the CJS-from-ESM translator (node:internal/m...

Open Graph Description: Version v24.15.0 (fails). Works on v24.14.1 and earlier. Platform: Linux x64 (also reproduced inside node:24.15.0-slim Docker image). Platform Linux x64 Subsystem loaders, module, specifically the ...

X Description: Version v24.15.0 (fails). Works on v24.14.1 and earlier. Platform: Linux x64 (also reproduced inside node:24.15.0-slim Docker image). Platform Linux x64 Subsystem loaders, module, specifically the ...

Opengraph URL: https://github.com/nodejs/node/issues/62786

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"require.extensions is undefined on synthetic require for CJS loaded through ESM loader (regression in v24.15.0)","articleBody":"### Version\n\nv24.15.0 (fails). Works on v24.14.1 and earlier. Platform: Linux x64 (also reproduced inside `node:24.15.0-slim` Docker image).\n\n### Platform\n\n```text\nLinux x64\n```\n\n### Subsystem\n\n`loaders`, `module`, specifically the CJS-from-ESM translator (`node:internal/modules/esm/translators`).\n\n### What steps will reproduce the bug?\n\n**Reproducer repo:** https://github.com/kabo/node-24.15-require-extensions-repro\n\n```sh\ngit clone https://github.com/kabo/node-24.15-require-extensions-repro\ncd node-24.15-require-extensions-repro/variant-b\ntouch yarn.lock\ncorepack yarn install\ncorepack yarn node run.mjs   # crashes on v24.15.0; succeeds on v24.14.1\n```\n\nThe reproducer is ~10 lines of code split across 4 files: a Yarn 4.14.1 PnP project (`package.json`), an ESM entry (`run.mjs`) that does `await import('dummy-cjs')`, and a trivial local CJS dependency (`dummy-cjs/index.cjs`) whose only relevant line is:\n\n```js\nconst oldJSHook = require.extensions['.js']  // line that throws on v24.15.0\n```\n\nSee the repo's `README.md` for full context, and `output-variant-b-24.14.0.txt` / `output-variant-b-24.15.0.txt` for the side-by-side outputs that establish the regression.\n\n\n### How often does it reproduce? Is there a required condition?\n\nEvery time on v24.15.0 when a CJS file is loaded via the ESM loader through a custom resolver/loader that produces a non-file URL (Yarn PnP loads from `file://.../cache/....zip/node_modules/...`).\n\n\n### What is the expected behavior? Why is that the expected behavior?\n\n`require.extensions` should be defined on the `require` function passed into the CJS module wrapper. It is deprecated (DEP0007) but has been part of the public `require` surface since 0.12. Multiple libraries still in active use (Next.js `next-config-ts/require-hook.js`, ts-node, esbuild-register, pirates, etc.) read it at CJS module top level.\n\nConfirmed behavior on v24.14.1:\n\n```\nnode: v24.14.1\ntypeof require.extensions: object\n.js hook: function\n```\n\n\n### What do you see instead?\n\nOn v24.15.0:\n\n```\n[dummy-cjs] node: v24.15.0\n[dummy-cjs] typeof require: function\n[dummy-cjs] typeof require.extensions: undefined\nfile:///.../.yarn/berry/cache/dummy-cjs-file-6872e80d06-10.zip/node_modules/dummy-cjs/index.cjs:6\nconst oldJSHook = require.extensions['.js']\n                                    ^\n\nTypeError: Cannot read properties of undefined (reading '.js')\n    at Object.\u003canonymous\u003e (file:///.../.yarn/berry/cache/dummy-cjs-file-6872e80d06-10.zip/node_modules/dummy-cjs/index.cjs:6:37)\n    at loadCJSModule (node:internal/modules/esm/translators:185:3)\n    at ModuleWrap.\u003canonymous\u003e (node:internal/modules/esm/translators:231:7)\n    at ModuleJob.run (node:internal/modules/esm/module_job:437:25)\n    at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\n    at async node:internal/modules/esm/loader:639:26\n    at async file:///.../run.mjs:1:1\n\nNode.js v24.15.0\n```\n\nNote `typeof require` is `function` — a `require` is provided — but `require.extensions` is `undefined` on it, which differs from what CJS modules (and the `Module.prototype.require` used in filesystem-loaded CJS) see.\n\n\n### Additional information\n\n- **Suspected cause**: [nodejs/node#61769](https://github.com/nodejs/node/pull/61769) (\"lib: reduce cycles in esm loader and load it in snapshot\"), which rewrote the ESM loader initialization and the synthesised `require` construction for CJS-from-ESM. That PR landed in v24.x for the first time in v24.15.0.\n- **Related bug in same subsystem**: [nodejs/node#62012](https://github.com/nodejs/node/issues/62012) — EBADF fstat on zip fds in the same `createCJSModuleWrap` path. Same Node version, same Yarn PnP setup, different symptom in the same synthetic-CJS-wrap code.\n- **Real-world impact**: `next build` on Next.js 15+ fails for all users on Yarn PnP + Node 24.15 because Next's [`next/dist/build/next-config-ts/require-hook.js`](https://github.com/vercel/next.js/blob/canary/packages/next/src/build/next-config-ts/require-hook.ts#L35) reads `require.extensions['.js']` at module top level.\n- **Not reproducible** when the CJS file is loaded from a filesystem path (without a custom PnP-like loader in front), which suggests the bug is specific to how the ESM→CJS wrap constructs `require` for modules whose source URL is not a plain `file:///.../something.cjs`.\n- **Likely also affects v25.7+** since PR #61769 landed on v25 first.\n\n## Workaround\n\n- Downgrade to Node v24.14.1.\n- Or, for library authors reading `require.extensions`: use optional chaining (`require.extensions?.['.js']`) so the call at module load doesn't throw.\n","author":{"url":"https://github.com/kabo","@type":"Person","name":"kabo"},"datePublished":"2026-04-17T10:43:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/62786/node/issues/62786"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:69764a58-1b7d-2c84-c089-f2cd469bca8f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9858:6A6D7:2C4F03D:3EFE856:6A4CFEDB
html-safe-nonce0ecb51817d163ce3b6502fc544645702baf6b585e1a4d9f8dd44cead96c982b4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5ODU4OjZBNkQ3OjJDNEYwM0Q6M0VGRTg1Njo2QTRDRkVEQiIsInZpc2l0b3JfaWQiOiIyMTk2ODU0Njg1Mzk4MDA3NTE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac193a60e86ddf26afbe1dbfce7074abdd6c943fc5af5a18a7e1d9870ab7a7a708
hovercard-subject-tagissue:4281998001
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/nodejs/node/62786/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4c9f556cc945c51bccf2de573e7954c49558553b158ccc434bd87c008231656a/nodejs/node/issues/62786
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4c9f556cc945c51bccf2de573e7954c49558553b158ccc434bd87c008231656a/nodejs/node/issues/62786
og:image:altVersion v24.15.0 (fails). Works on v24.14.1 and earlier. Platform: Linux x64 (also reproduced inside node:24.15.0-slim Docker image). Platform Linux x64 Subsystem loaders, module, specifically the ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekabo
hostnamegithub.com
expected-hostnamegithub.com
None31e4db13a9e20081f2fac78f441659a6576e582bbb15e153f9c7fb6473aa29f5
turbo-cache-controlno-preview
go-importgithub.com/nodejs/node git https://github.com/nodejs/node.git
octolytics-dimension-user_id9950313
octolytics-dimension-user_loginnodejs
octolytics-dimension-repository_id27193779
octolytics-dimension-repository_nwonodejs/node
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id27193779
octolytics-dimension-repository_network_root_nwonodejs/node
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasefb70bd3c4b2bec429781b65419e912c66e2d5581
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/nodejs/node/issues/62786#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F62786
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F62786
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=nodejs%2Fnode
Reloadhttps://github.com/nodejs/node/issues/62786
Reloadhttps://github.com/nodejs/node/issues/62786
Reloadhttps://github.com/nodejs/node/issues/62786
Please reload this pagehttps://github.com/nodejs/node/issues/62786
nodejs https://github.com/nodejs
nodehttps://github.com/nodejs/node
Please reload this pagehttps://github.com/nodejs/node/issues/62786
Notifications https://github.com/login?return_to=%2Fnodejs%2Fnode
Fork 36k https://github.com/login?return_to=%2Fnodejs%2Fnode
Star 118k https://github.com/login?return_to=%2Fnodejs%2Fnode
Code https://github.com/nodejs/node
Issues 1.4k https://github.com/nodejs/node/issues
Pull requests 958 https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality 0 https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
Code https://github.com/nodejs/node
Issues https://github.com/nodejs/node/issues
Pull requests https://github.com/nodejs/node/pulls
Actions https://github.com/nodejs/node/actions
Projects https://github.com/nodejs/node/projects
Security and quality https://github.com/nodejs/node/security
Insights https://github.com/nodejs/node/pulse
require.extensions is undefined on synthetic require for CJS loaded through ESM loader (regression in v24.15.0)https://github.com/nodejs/node/issues/62786#top
duplicateIssues and PRs that are duplicates of other issues or PRs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22duplicate%22
https://github.com/kabo
kabohttps://github.com/kabo
on Apr 17, 2026https://github.com/nodejs/node/issues/62786#issue-4281998001
https://github.com/kabo/node-24.15-require-extensions-reprohttps://github.com/kabo/node-24.15-require-extensions-repro
nodejs/node#61769https://github.com/nodejs/node/pull/61769
nodejs/node#62012https://github.com/nodejs/node/issues/62012
next/dist/build/next-config-ts/require-hook.jshttps://github.com/vercel/next.js/blob/canary/packages/next/src/build/next-config-ts/require-hook.ts#L35
lib: include ESM loader in the built-in snapshot #61769https://github.com/nodejs/node/pull/61769
duplicateIssues and PRs that are duplicates of other issues or PRs.https://github.com/nodejs/node/issues?q=state%3Aopen%20label%3A%22duplicate%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.