vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.83k stars 26.85k forks source link

Error: Cannot find module 'node:stream/web' using with-electron-typescript example's dev command #49581

Open hajime-lux opened 1 year ago

hajime-lux commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Fri Jan 27 02:56:13 UTC 2023
    Binaries:
      Node: 18.16.0
      npm: 9.5.1
      Yarn: 1.22.5
      pnpm: 8.5.0
    Relevant packages:
      next: 13.4.1
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

Which example does this report relate to?

with-electron-typescript

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

run dev version, then

Error: Cannot find module 'node:stream/web'

occurs.

in package.json, with-electron-typescript uses electron (^13)

"electron": "^13",

electron(^13) bundles node(v14.16)

https://www.electronjs.org/docs/latest/tutorial/electron-timelines

but WritableStream in node:stream/web

https://github.com/vercel/next.js/blob/v13.4.1/packages/next/src/lib/download-wasm-swc.ts#L9

was added in v16.5.0

https://nodejs.org/api/webstreams.html

version of electron is too old to use the latest next

Expected Behavior

start dev version without error.

To Reproduce

start dev version

$ npm run dev

error occurs

(node:6688) UnhandledPromiseRejectionWarning: Error: Cannot find module 'node:stream/web'
Require stack:
- /xxx/with-electron-typescript-app/node_modules/next/dist/lib/download-wasm-swc.js
- /xxx/with-electron-typescript-app/node_modules/next/dist/build/swc/index.js
- /xxx/with-electron-typescript-app/node_modules/next/dist/build/output/store.js
- /xxx/with-electron-typescript-app/node_modules/next/dist/build/output/index.js
- /xxx/with-electron-typescript-app/node_modules/next/dist/server/dev/next-dev-server.js
- /xxx/with-electron-typescript-app/node_modules/next/dist/server/next.js
- /xxx/with-electron-typescript-app/node_modules/electron-next/index.js
- /xxx/with-electron-typescript-app/main/index.js
- /xxx/with-electron-typescript-app/node_modules/electron/dist/resources/default_app.asar/main.js
-
    at Module._resolveFilename (internal/modules/cjs/loader.js:887:15)
    at Function.n._resolveFilename (electron/js2c/browser_init.js:257:1128)
    at /xxx/with-electron-typescript-app/node_modules/next/dist/server/require-hook.js:180:36
    at Module._load (internal/modules/cjs/loader.js:732:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12913)
    at Module.require (internal/modules/cjs/loader.js:959:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/xxx/with-electron-typescript-app/node_modules/next/dist/lib/download-wasm-swc.js:63:29)
    at Module._compile (internal/modules/cjs/loader.js:1078:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1108:10)
(Use `electron --trace-warnings ...` to show where the warning was created)
(node:6688) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
(node:6688) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
danielrotaermel commented 1 year ago

My current workaround: npm install electron@latest

XxGodmoonxX commented 12 months ago

My current workaround: npm install electron@latest

@danielrotaermel that was helpful. thank you.