René's URL Explorer Experiment


Title: `require()` in an imported CommonJS module returns empty exports for a re-exported dependency after `require.cache` deletion · Issue #67611 · nodejs/node · GitHub

Open Graph Title: `require()` in an imported CommonJS module returns empty exports for a re-exported dependency after `require.cache` deletion · Issue #67611 · nodejs/node

X Title: `require()` in an imported CommonJS module returns empty exports for a re-exported dependency after `require.cache` deletion · Issue #67611 · nodejs/node

Description: Disclosure: AI helped narrow this down and draft the report. I've read everything, ran the repro and checked the source references. I can open a PR with a test if this is considered a bug. Version 26.13.1 Platform Darwin Mac 27.0.0 Darwi...

Open Graph Description: Disclosure: AI helped narrow this down and draft the report. I've read everything, ran the repro and checked the source references. I can open a PR with a test if this is considered a bug. Version ...

X Description: Disclosure: AI helped narrow this down and draft the report. I've read everything, ran the repro and checked the source references. I can open a PR with a test if this is considered a bug. Vers...

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

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`require()` in an imported CommonJS module returns empty exports for a re-exported dependency after `require.cache` deletion","articleBody":"> Disclosure: AI helped narrow this down and draft the report. I've read everything, ran the repro and checked the source references.\n\nI can open a PR with a test if this is considered a bug.\n\n### Version\n\n26.13.1\n\n### Platform\n\n```text\nDarwin Mac 27.0.0 Darwin Kernel Version 27.0.0: Tue Aug 11 21:05:48 PDT 2026; root:xnu-13432.1.9~1/RELEASE_ARM64_T6041 arm64\n```\n\n### Subsystem\n\n`module`\n\n### What steps will reproduce the bug?\n\nSave as `repro.mjs` and run `node repro.mjs`:\n\n```js\nimport { mkdtempSync, realpathSync, writeFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { tmpdir } from 'node:os'\nimport { join } from 'node:path'\nimport { pathToFileURL } from 'node:url'\n\nconst require = createRequire(import.meta.url)\nconst dir = realpathSync(mkdtempSync(join(tmpdir(), 'repro-')))\nconst entry = join(dir, 'entry.cjs')\nconst dep = join(dir, 'dep.cjs')\n\n// Works as expected when changed to: module.exports = { nested: { dep: require('./dep.cjs') } }\nwriteFileSync(entry, \"module.exports = require('./dep.cjs')\\n\")\n\nfor (const value of [1, 2, 3]) {\n    writeFileSync(dep, `module.exports = { value: ${value} }\\n`)\n    delete require.cache[entry]\n    delete require.cache[dep]\n    const { default: exports } = await import(`${pathToFileURL(entry)}?v=${value}`)\n    console.log(value, exports)\n}\n```\n\n### How often does it reproduce? Is there a required condition?\n\nAlways, from the second `import()` on. Conditions:\n\n- The CommonJS file is loaded with `import()`, not `require()`. Replacing the import with `require(entry)` prints the expected values.\n- Its export has a shape the CommonJS lexer reports as a re-export: `module.exports = require('./dep.cjs')`, `module.exports = { ...require('./dep.cjs') }`, or `module.exports = { key: require('./dep.cjs') }`. With the `require` nested one level deeper, or assigned to a variable first, it works.\n- Both files were deleted from `require.cache` and the file is imported again under a new URL. This is the usual way tools reload a config file and its dependencies.\n\n### What is the expected behavior? Why is that the expected behavior?\n\n```\n1 { value: 1 }\n2 { value: 2 }\n3 { value: 3 }\n```\n\nBoth modules were removed from `require.cache`, so both should be evaluated again, as they are when the entry is loaded with `require()` or when the `require` call is not in a re-export position. There is no circular dependency between the two files.\n\n### What do you see instead?\n\n```\n1 { value: 1 }\n2 {}\n3 {}\n```\n\nIf `dep.cjs` contains a syntax error at the second import, the import also resolves with `{}` and no error is thrown.\n\n### Additional information\n\nFrom reading `lib/internal/modules/cjs/loader.js` and `lib/internal/modules/esm/translators.js`, this seems to be the cause:\n\n1. `cjsPreparseModuleExports()` adds an unloaded `Module._cache` entry (marked `kIsCachedByESMLoader`) for each re-exported dependency before the imported file runs.\n2. On the first import, the file's `require('./dep.cjs')` goes through the regular cache check in `Module._load()`, which recognizes such an entry, marks it `kModuleCircularVisited` and loads it.\n3. That load also records the request in `relativeResolveCache`. On later imports the fast path at the top of `Module._load()` finds the new, still unloaded entry and returns `getExportsForCircularRequire(cachedModule)` for any `!cachedModule.loaded`, without the `kIsCachedByESMLoader` / `kModuleCircularVisited` check the regular path has.\n\nTwo observations support this: logging `require.cache[dep]` from inside `entry.cjs` right before its `require()` shows the same unloaded entry with `kIsCachedByESMLoader` set on every import, including the first one that works. And giving the entry a different but equivalent request string on each import (`./x/../dep.cjs`, `./x/../x/../dep.cjs`, …), so the fast path cannot hit, makes every import return the correct exports.\n\nApplying the same check in the fast path, and falling through to the regular path for an ESM-loader entry that has not been visited, looks like it would fix it.\n\nFound through a dev server that reloads Tailwind CSS config files this way: a config written as `module.exports = require('./shared.cjs')` lost its values on the second edit. Possibly relevant to #61767.\n\nAlso reproduces on v24.22.3, v22.23.5 and v22.18.0.","author":{"url":"https://github.com/dcastil","@type":"Person","name":"dcastil"},"datePublished":"2026-11-19T12:23:50Z","url":"https://github.com/nodejs/node/issues/67611"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4d7a61f3-5310-de08-5330-7e40b8a2d56b
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idDEB8:1D768B:4FA5EE:681580:6B061EFA
html-safe-nonce7a0a60ca9061e18b384cd6b7926a3cea55bf4a9e4e9c8d2766e7fe5cd0090114
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERUI4OjFENzY4Qjo0RkE1RUU6NjgxNTgwOjZCMDYxRUZBIiwidmlzaXRvcl9pZCI6IjgyNDY3MDUyMDI5MTM0ODQ1MzgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacbd6dfa39c794844be0c3702dd0472d1941b7f19c2e884da17515f6b6094bef36
hovercard-subject-tagissue:6489502469
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/67611/issue_layout
twitter:imagehttps://opengraph.githubassets.com/662fd66a11cdba29293e0e1f5a5bb2e31add08764e42b68810b536d0cf71359e/nodejs/node/issues/67611
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/662fd66a11cdba29293e0e1f5a5bb2e31add08764e42b68810b536d0cf71359e/nodejs/node/issues/67611
og:image:altDisclosure: AI helped narrow this down and draft the report. I've read everything, ran the repro and checked the source references. I can open a PR with a test if this is considered a bug. Version ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamedcastil
hostnamegithub.com
expected-hostnamegithub.com
None9a7c5824b75ea2ec5e3de73a483229c7bb9f32a774ffd401f010dd9bacf1483d
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
releaseb25c3080e84402f75431d8dc7a96b2635219cec7
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/nodejs/node/issues/67611#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F67611
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fnodejs%2Fnode%2Fissues%2F67611
Sign uphttps://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/67611
Reloadhttps://github.com/nodejs/node/issues/67611
Reloadhttps://github.com/nodejs/node/issues/67611
nodejshttps://github.com/nodejs
nodehttps://github.com/nodejs/node
Codehttps://github.com/nodejs/node
Issues630 (630)https://github.com/nodejs/node/issues
Pull requests660 (660)https://github.com/nodejs/node/pulls
Actionshttps://github.com/nodejs/node/actions
Projectshttps://github.com/nodejs/node/projects
Security and qualityhttps://github.com/nodejs/node/security
Insightshttps://github.com/nodejs/node/insights
https://github.com/nodejs/node
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/67611
New issuehttps://github.com/login?return_to=https://github.com/nodejs/node/issues/67611
#67761https://github.com/nodejs/node/pull/67761
require() in an imported CommonJS module returns empty exports for a re-exported dependency after require.cache deletionhttps://github.com/nodejs/node/issues/67611#top
#67761https://github.com/nodejs/node/pull/67761
https://github.com/dcastil
dcastilhttps://github.com/dcastil
on Nov 19, 2026https://github.com/nodejs/node/issues/67611#issue-6489502469
#61767https://github.com/nodejs/node/pull/61767
dcastilhttps://github.com/dcastil
on Nov 19, 2026https://github.com/nodejs/node/issues/67611#event-36651104926
Configurator: Link the Node issue behind the require-first config loa…https://github.com/dcastil/tailwind-merge/commit/9b67b6ce0f334e14f45e031cd31061ebba907d54
9b67b6chttps://github.com/dcastil/tailwind-merge/commit/9b67b6ce0f334e14f45e031cd31061ebba907d54
https://github.com/Pranshu12354
Pranshu12354https://github.com/Pranshu12354
on Nov 24, 2026https://github.com/nodejs/node/issues/67611#issuecomment-7142695668
Pranshu12354https://github.com/Pranshu12354
on Nov 24, 2026https://github.com/nodejs/node/issues/67611#event-37174202920
module: fix require() of re-exported CJS dep after cache deletionhttps://github.com/Pranshu12354/node/commit/99da18885f44cf01b858751552064c9562e0f165
99da188https://github.com/Pranshu12354/node/commit/99da18885f44cf01b858751552064c9562e0f165
module: fix require() of re-exported CJS dep after cache deletionhttps://github.com/Pranshu12354/node/commit/30cb79d0357017d099b9575414c68a9a5ae191fd
30cb79dhttps://github.com/Pranshu12354/node/commit/30cb79d0357017d099b9575414c68a9a5ae191fd
Sign up for freehttps://github.com/signup?return_to=https://github.com/nodejs/node/issues/67611
Sign in to commenthttps://github.com/login?return_to=https://github.com/nodejs/node/issues/67611
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

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.