Skip to content

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

Open

Description

@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:

#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");

Activity

  1. added
    bug
    app
    windows-os
    tool-calls
    on Aug 24, 2026
  2. th3nolo commented on Aug 29, 2026

    @th3nolo

    Independent reproduction on a newer Windows Desktop build, with an important impact correction after end-to-end Browser Plugin validation.

    Environment:

    • Codex Desktop AppX: 26.825.4187.0
    • Platform: Microsoft Windows NT 10.0.26200.9278 x64
    • Agent model: gpt-5.6-sol
    • Task type: local Windows task (workspace_kind=projectless)
    • Sandbox mode: workspace-write
    • Shell: PowerShell 7.6.4
    • Browser and Chrome plugins: installed/enabled (reported by the user)
    • node_repl: enabled and callable (node_repl_disabled=false)

    After a clean mcp__node_repl__js_reset, the direct import still fails:

    await import("playwright");

    Observed:

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

    This confirms the CommonJS interoperability bug persists on AppX 26.825.4187.0 and under workspace-write.

    However, this does not block the normal Browser Plugin workflow in this build. The plugin's packaged entry point is scripts/browser-client.mjs, not a direct Playwright import. Using that entry point:

    1. setupBrowserRuntime() completed.
    2. agent.browsers.getDefault() selected the Codex in-app browser.
    3. browser.user.openTabs() returned the two visible tabs.
    4. Claiming the existing preview tab and calling tab.playwright.domSnapshot() succeeded.

    The issue therefore remains valid for direct ESM-to-CommonJS interoperability, but its impact should not be interpreted as proof that Browser Plugin control is unavailable. Loading bundled Playwright with createRequire() also succeeds, although it was not needed for the supported Browser Plugin path.

  3. lymiran commented on Sep 27, 2026

    @lymiran

    Reproduced on a newer Windows desktop build with the bundled Browser plugin explicitly selected.

    Environment:

    • OpenAI.Codex app package: 26.924.2738.0 (x64)
    • Bundled Codex runtime: 0.158.0-alpha.2.1
    • Bundled playwright / playwright-core: 1.57.0
    • Windows
    • Browser invoked explicitly with @Browser

    Minimal failure inside the Browser-associated persistent Node REPL:

    await import("playwright")

    Observed:

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

    The same error occurs with await import("playwright-core"). Resetting the Node REPL kernel and retrying once does not change the result. Inspection shows playwright-core/index.mjs default-importing the bundled CommonJS ./index.js, matching this issue's interoperability boundary. The failure happens before a page or browser target is opened, so it is independent of website permissions, login state, cookies, or the target site.

    No application files or bundled packages were modified while reproducing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appbugtool-callswindows-os

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions