I am encountering a runtime crash immediately upon starting my development server. The server throws a ReferenceError: module is not defined because it is trying to execute CommonJS code inside the @shopify/mini-oxygen worker environment, which strictly expects ESM and does not have the module object defined.
The error traces back to @sanity/visual-editing importing react/compiler-runtime.js (from React 19.2.4), which is formatted as CommonJS.
Steps to Reproduce:
- Clone the repository / set up a fresh Hydrogen headless install.
- Run
pnpm install (using React 19.2.4 and Node 22).
- Set up environment variables.
- Run
pnpm dev to start the Mini-Oxygen development server.
- Attempt to load the application.
Expected Behavior:
The application should render successfully without CommonJS/ESM compatibility errors in the Mini-Oxygen worker.
Actual Behavior:
The server crashes and throws a 500 error with the following stack trace:
ReferenceError: module is not defined
at C:/GitHub/new-ecommerc-headless/node_modules/.pnpm/react@19.2.4/node_modules/react/compiler-runtime.js:13:3
at Object.runInlinedModule (GitHub/new-ecommerc-headless/node_modules/.pnpm/@shopify+mini-oxygen@4.0.2__056f10e53a824ad3bbcdf498809f17a6/node_modules/@shopify/mini-oxygen/dist/vite/worker-entry.js:1418:17)
at ModuleRunner.directRequest (GitHub/new-ecommerc-headless/node_modules/.pnpm/@shopify+mini-oxygen@4.0.2__056f10e53a824ad3bbcdf498809f17a6/node_modules/@shopify/mini-oxygen/dist/vite/worker-entry.js:1281:82)
at ModuleRunner.cachedRequest (GitHub/new-ecommerc-headless/node_modules/.pnpm/@shopify+mini-oxygen@4.0.2__056f10e53a824ad3bbcdf498809f17a6/node_modules/@shopify/mini-oxygen/dist/vite/worker-entry.js:1176:28)
at request (GitHub/new-ecommerc-headless/node_modules/.pnpm/@shopify+mini-oxygen@4.0.2__056f10e53a824ad3bbcdf498809f17a6/node_modules/@shopify/mini-oxygen/dist/vite/worker-entry.js:1225:79)
at C:/GitHub/new-ecommerc-headless/node_modules/.pnpm/@sanity+visual-editing@5.3._8894b6fe2021e048202f96b184033855/node_modules/@sanity/visual-editing/dist/_chunks-es/VisualEditing.js?v=69b4f217:13:182
at Object.runInlinedModule (GitHub/new-ecommerc-headless/node_modules/.pnpm/@shopify+mini-oxygen@4.0.2__056f10e53a824ad3bbcdf498809f17a6/node_modules/@shopify/mini-oxygen/dist/vite/worker-entry.js:1418:11)
at ModuleRunner.directRequest (GitHub/new-ecommerc-headless/node_modules/.pnpm/@shopify+mini-oxygen@4.0.2__056f10e53a824ad3bbcdf498809f17a6/node_modules/@shopify/mini-oxygen/dist/vite/worker-entry.js:1281:61)
at ModuleRunner.cachedRequest (GitHub/new-ecommerc-headless/node_modules/.pnpm/@shopify+mini-oxygen@4.0.2__056f10e53a824ad3bbcdf498809f17a6/node_modules/@shopify/mini-oxygen/dist/vite/worker-entry.js:1177:79)
at C:/GitHub/new-ecommerc-headless/node_modules/.pnpm/@sanity+visual-editing@5.3._8894b6fe2021e048202f96b184033855/node_modules/@sanity/visual-editing/dist/react/index.js?v=69b4f217:12:31
Environment Info:
- Node Version: v22
- Package Manager: pnpm
- OS: Windows
- React:
19.2.4
- @sanity/visual-editing:
5.3.x
- @shopify/mini-oxygen:
4.0.2
I am encountering a runtime crash immediately upon starting my development server. The server throws a
ReferenceError: module is not definedbecause it is trying to execute CommonJS code inside the@shopify/mini-oxygenworker environment, which strictly expects ESM and does not have themoduleobject defined.The error traces back to
@sanity/visual-editingimportingreact/compiler-runtime.js(from React 19.2.4), which is formatted as CommonJS.Steps to Reproduce:
pnpm install(using React 19.2.4 and Node 22).pnpm devto start the Mini-Oxygen development server.Expected Behavior:
The application should render successfully without CommonJS/ESM compatibility errors in the Mini-Oxygen worker.
Actual Behavior:
The server crashes and throws a 500 error with the following stack trace:
Environment Info:
19.2.45.3.x4.0.2