Repository: next.js
Issue: [Next 15] Preloading multiple modules prevents the `dev` server from running
Labels: bug,Runtime

### Link to the code that reproduces this issue

- [Code sandbox](https://codesandbox.io/p/devbox/next-15--multiple-requires-mqyt2z?file=%2Fpackage.json%3A5%2C27&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clxz6c9qn00063b6jqebc9pka%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clxz6c9qn00023b6j6ln4mfs6%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clxz6c9qn00043b6jr0c52u2p%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clxz6c9qn00053b6j391v6qhx%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B60%252C40%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clxz6c9qn00023b6j6ln4mfs6%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clxz6c9qn00013b6j6mg6pm1t%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522clxz6dm9o00023b6kcfchvk3x%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A5%252C%2522startColumn%2522%253A27%252C%2522endLineNumber%2522%253A5%252C%2522endColumn%2522%253A27%257D%255D%252C%2522filepath%2522%253A%2522%252Fpackage.json%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clxz6c9qn00023b6j6ln4mfs6%2522%252C%2522activeTabId%2522%253A%2522clxz6dm9o00023b6kcfchvk3x%2522%257D%252C%2522clxz6c9qn00053b6j391v6qhx%2522%253A%257B%2522id%2522%253A%2522clxz6c9qn00053b6j391v6qhx%2522%252C%2522activeTabId%2522%253A%2522clxz7kqc2003j3b6krzro11eg%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522SANDBOX_INFO%2522%252C%2522isCloud%2522%253Atrue%252C%2522id%2522%253A%2522clxz7kqc2003j3b6krzro11eg%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%252C%2522clxz6c9qn00043b6jr0c52u2p%2522%253A%257B%2522id%2522%253A%2522clxz6c9qn00043b6jr0c52u2p%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clxz7hoty001o3b6kvyq21xsf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clxz7nmhi001ydjipexgm0vth%2522%257D%255D%252C%2522activeTabId%2522%253A%2522clxz7hoty001o3b6kvyq21xsf%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D)

### To Reproduce

1. Attempt to start the application via `npm run dev`.
2. Running the app will fail.

### Current vs. Expected behavior

In **Next 15 RC**, preloading multiple modules via `NODE_MODULES=--require ./module1 --require ./module2` throws an error that prevents the server from running. 

- Although I can tell by the logs that the modules are properly preloaded, the server still does not run.

Example:

```json
  "scripts": {
    "dev": "NODE_OPTIONS='--require ./required-module1 --require ./required-module2' next dev",
  }
```

#### Current behavior

```sh
➜  workspace git:(master) ✗ npm run dev

> dev
> NODE_OPTIONS='--require ./required-module1 --require ./required-module2' next dev

===== module 1
===== module 2
node:internal/modules/cjs/loader:1051
  throw err;
  ^

Error: Cannot find module './required-module1 ./required-module2'
Require stack:
- internal/preload
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at internalRequire (node:internal/modules/cjs/loader:166:19)
    at Module._preloadModules (node:internal/modules/cjs/loader:1420:5)
    at loadPreloadModules (node:internal/process/pre_execution:705:5)
    at setupUserModules (node:internal/process/pre_execution:170:3)
    at prepareExecution (node:internal/process/pre_execution:132:5)
    at prepareMainThreadExecution (node:internal/process/pre_execution:55:3)
    at node:internal/main/run_main_module:10:1 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'internal/preload' ]
}

Node.js v20.9.0
```

#### Expected behavior
- Next 15 should start.
- For further context, this works in a [Next 14](https://codesandbox.io/p/devbox/next-14--multiple-requires-wfvn2z?layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clxz6c9qn00063b6jqebc9pka%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clxz6c9qn00023b6j6ln4mfs6%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clxz6c9qn00043b6jr0c52u2p%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clxz6c9qn00053b6j391v6qhx%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clxz6c9qn00023b6j6ln4mfs6%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clxz6c9qn00013b6j6mg6pm1t%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522clxz6xtut00023b6knfkzggd8%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A4%252C%2522startColumn%2522%253A1%252C%2522endLineNumber%2522%253A5%252C%2522endColumn%2522%253A1%257D%255D%252C%2522filepath%2522%253A%2522%252Fpackage.json%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clxz6c9qn00023b6j6ln4mfs6%2522%252C%2522activeTabId%2522%253A%2522clxz6xtut00023b6knfkzggd8%2522%257D%252C%2522clxz6c9qn00053b6j391v6qhx%2522%253A%257B%2522id%2522%253A%2522clxz6c9qn00053b6j391v6qhx%2522%252C%2522activeTabId%2522%253A%2522clxz76vyd00ek3b6kanz6xbsn%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522SANDBOX_INFO%2522%252C%2522isCloud%2522%253Atrue%252C%2522id%2522%253A%2522clxz76vyd00ek3b6kanz6xbsn%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%252C%2522clxz6c9qn00043b6jr0c52u2p%2522%253A%257B%2522id%2522%253A%2522clxz6c9qn00043b6jr0c52u2p%2522%252C%2522activeTabId%2522%253A%2522clxz7sgbv00mh3b6k4gaviiyb%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clxz7sgbv00mh3b6k4gaviiyb%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clxz7sgew000vdpifck0x4iff%2522%257D%255D%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D) sandbox:

```sh
➜  workspace git:(master) ✗ npm run dev

> dev
> NODE_OPTIONS='--require ./required-module1 --require ./required-module2' next dev

===== module 1
===== module 2
===== module 1
===== module 2
  ▲ Next.js 14.2.4
  - Local:        http://localhost:3000

 ✓ Starting...
 ✓ Ready in 1952ms
```

### Provide environment information

```bash
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.0.0-canary.47 // Latest available version is detected (15.0.0-canary.47).
  eslint-config-next: N/A
  react: 19.0.0-rc-6f23540c7d-20240528
  react-dom: 19.0.0-rc-6f23540c7d-20240528
  typescript: 5.3.3
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

Runtime

### Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

### Additional context

- I could reproduce this behavior all the way back to [15.0.0-canary.0](https://www.npmjs.com/package/next/v/15.0.0-canary.0).
- Preloading does work if only include a single module, i.e. only one `--require`.