saltyshiomix / nextron

⚡ Next.js + Electron ⚡
https://npm.im/nextron
MIT License
3.88k stars 223 forks source link

Nextron with Electron v22.0.0 or newer show only white page #384

Closed noevermaurice closed 1 year ago

noevermaurice commented 1 year ago

Description: When using Nextron along with Next.js in version 13.3.3 and Electron in version 22.0.0, an issue occurs where the application displays a white screen upon start and fails to load the expected content. No error messages or warnings are displayed to indicate the problem.

Steps to Reproduce:

Use Nextron with Next.js in version 13.3.3 and Electron in version 22.0.0. Start the application. Expected Behavior: The application should successfully start and display the expected content.

Current Behavior: The application starts but only shows a white screen, failing to load the expected content.

Additional Information:

This issue occurs when using Nextron, Next.js in version 13.3.3, and Electron in version 22.0.0 together. No error messages or warnings are shown to indicate the problem. Other features of the application may function correctly, but the main content is not displayed.

eliasiturri commented 1 year ago

I had the same issue. This line on the terminal

(node:77265) UnhandledPromiseRejectionWarning: Error: ERR_INVALID_URL (-300) loading 'http://localhost:./home'

led me to look for the missing port variable. As a temporary fix, you can locate the line

const port = process.argv[2];

in the file background.js

and replace it with

const port = 8888;

or whatever the port you are using for development is.

I'm not sure where the process arguments are taken from, but this can probably be solved by just modifying the command used to call electron or next or something.

Hope this helps you continue development

AbdeenM commented 1 year ago

Same problem as OP, can confirm same problem is occurring for any Next v13.x and Electron v22+. No errors or any logs from my end though

noevermaurice commented 1 year ago

thank you for trying to help i got this error

❯ yarn dev yarn run v1.22.19 warning ../package.json: No license field $ nextron

DevTools listening on ws://127.0.0.1:5858/devtools/browser/d430a5c1-f4e3-4607-8d01-a3c165360dd1

hockyy commented 1 year ago

Everyone is having the same issue: https://github.com/saltyshiomix/nextron/issues/346#issuecomment-1536314824

uzunhair commented 1 year ago

Первый шаг, Вы должны поправить настройки и включить в webPreferences nodeIntegration: false, contextIsolation: true, enableBlinkFeatures: '', То есть должно получиться так image

Далее вы должны найти другие проблемы. В моем случае была проблема в /renderer/next.config.js Вы должны либо удалить целиком файл либо закомментировать следующие строки image

eastrd commented 1 year ago

Hello, any updates on this issue?

uzunhair commented 1 year ago

Hello, any updates on this issue?

I wrote an answer to your question, look at my comment on the above

makeusabrew commented 1 year ago

Upgrading Electron to latest (26.2.2 at the time of writing) seems to work okay for me in dev and production, with the caveat being that I was already using nodeIntegration: false and contextIsolation: true (per Electron recommendations and best practices). I don't speak Russian but I'm pretty sure that's what @uzunhair was indicating in his comments earlier in this thread!

saltyshiomix commented 1 year ago

@makeusabrew Thank you for trying it! I confirmed it works fine by removing config.target = 'electron-renderer' in next.config.js 💯 (v22 - v26 are OK!)

@noevermaurice and everyone, Feel free to reopen the issue if any troubles :)

MaxLiebsch commented 1 year ago

Dear, the problem persist for me.

I confirmed it works fine by removing config.target = 'electron-renderer' in next.config.js 💯

That does not work, if nodeIntegration: true and contextIsolation: false

saltyshiomix commented 1 year ago

@MaxLiebsch

Could you let me know, are you using IPC? (ipcMain and ipcRenderer)

MaxLiebsch commented 1 year ago

Dear @saltyshiomix, thanks that you taking time to reply.

We use nextron in two production applications.

We are importing ipcRenderer in the renderer process, so removing config.target results in missing dependencies for fs.

Any updates?

rinalditomas commented 11 months ago

I'm facing the same issue. Initially, I encountered problems when attempting to build for Windows, prompting me to upgrade Electron to the current version, 27.0.0.

After upgrading Electron, the build process worked well, but I'm now encountering a blank page issue when running the application in dev mode. I've experimented with different configurations, such as disabling nodeIntegration and enabling contextIsolation. However, these changes resulted in a frontend error: "Uncaught ReferenceError: global is not defined." Additionally, when I removed config.target = 'electron-renderer', I encountered another error: "Module not found: Can't resolve 'fs'."

I also attempted to resolve this by downgrading to version 26.2.2 and follow the previously mentioned steps, but unfortunately, the issue persisted. Are there any updates or solutions available for this problem?

My versions:

   "electron": "27.0.0",
   "electron-builder": "^23.3.3",
   "next": "^12.2.5",
    "nextron": "^8.12.0",
openarun commented 3 months ago

Related to #346 and not fixed.

hockyy commented 1 month ago

just slowly port your app. You can achieve the same functionalities with nodeIntegration false and contextIsolation true

I ported my nextron v8 to v9, electron 21 to 31, next 13 to 14, it takes some times, but its not impossible.

https://github.com/hockyy/miteiru/pull/60