[Windows] node_repl lacks CommonJS default interoperability: import("playwright") fails

Open 💬 0 comments Opened Aug 24, 2026 by azarenkovg

What version of the Codex App are you using?

26.818.5345.0

Detected through Get-AppxPackage -Name OpenAI.Codex.

What subscription do you have?

Pro

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What issue are you seeing?

The persistent node_repl tool cannot dynamically import Playwright because its module loader does not provide Node-compatible default interoperability when an ES module imports a CommonJS module.

The following expression fails inside mcp__node_repl__js:

await import("playwright");

Error:

The requested module './index.js' does not provide an export named 'default'

This is not a missing package or incompatible Node runtime:

  • Playwright 1.62.1 is installed and discoverable by node_repl.
  • js_add_node_module_dir accepts the package's node_modules directory.
  • The exact Node executable bundled with Codex successfully imports the same package.
  • Loading Playwright through Node's createRequire() succeeds inside the same persistent REPL.
  • No browser launch is required to reproduce the failure.

The failing interoperability boundary can be isolated to playwright-core/index.mjs, which contains:

import playwright from './index.js';

./index.js is CommonJS. Native Node provides module.exports as the default import, while the node_repl loader reports that no default export exists.

What steps can reproduce the bug?

Environment:

  • Codex App: 26.818.5345.0
  • Platform: Windows 11 x64
  • Embedded Node: v24.19.0
  • Playwright: 1.62.1
  • Sandbox mode: danger-full-access
  • Session ID: 01a02f5d-2d16-7511-86f7-d1b384135e9d
  1. Create a temporary package and install Playwright:
mkdir playwright-repro
cd playwright-repro
pnpm init
pnpm add --save-dev playwright@1.62.1
  1. Verify that the Codex-bundled Node executable imports it successfully:
& "$env:LOCALAPPDATA\OpenAI\Codex\runtimes\cua_node\<runtime-hash>\bin\node.exe" `
  -e "import('playwright').then((module) => console.log({ chromium: !!module.chromium, hasDefault: !!module.default }))"

Observed output:

{ chromium: true, hasDefault: true }
  1. Add the temporary package's absolute node_modules directory through mcp__node_repl__js_add_node_module_dir.

The tool returns successfully.

  1. In mcp__node_repl__js, run:
await import("playwright");

Observed error:

The requested module './index.js' does not provide an export named 'default'
  1. The failure can be isolated by importing Playwright Core's ESM entry directly:
await import(
  "file:///C:/path/to/node_modules/playwright-core/index.mjs"
);

Observed error:

The requested module './index.js' does not provide an export named 'default'
  1. Loading the same package through Node's CommonJS loader succeeds inside node_repl:
var moduleBridge = await import("node:module");
var nodeRequire = moduleBridge.createRequire(
  "C:/path/to/playwright-repro/package.json"
);
var playwrightViaRequire = nodeRequire("playwright");

nodeRepl.write({
  chromium: !!playwrightViaRequire.chromium
});

Observed output:

{ chromium: true }

What is the expected behavior?

await import("playwright") inside node_repl should behave like the same dynamic import executed by the bundled Node runtime.

When an ES module default-imports a CommonJS module, node_repl should implement Node-compatible interoperability and expose module.exports as the default export.

Ideally, node_repl should delegate module evaluation to Node's native ESM loader rather than implementing different CommonJS interoperability semantics.

Additional information

Playwright's package exports correctly distinguish between ESM and CommonJS entry points:

{
  "exports": {
    ".": {
      "import": "./index.mjs",
      "require": "./index.js",
      "default": "./index.js"
    }
  }
}

The root Playwright ESM entry is selected, but importing eventually reaches this statement in playwright-core/index.mjs:

import playwright from './index.js';

That CommonJS default import is where node_repl fails.

The closest existing issue is #31780:

https://github.com/openai/codex/issues/31780

That issue concerns a mismatch between Playwright and installed Chromium revisions. Its await import("playwright") call succeeds, whereas this report fails before browser launch, so the two issues appear distinct.

Temporary workaround:

var moduleBridge = await import("node:module");
var nodeRequire = moduleBridge.createRequire(
  "C:/path/to/playwright-repro/package.json"
);
var playwright = nodeRequire("playwright");

View original on GitHub ↗