saltyshiomix / nextron

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

Error when running 'npm run start' in my Nextron application #417

Open Sine03 opened 11 months ago

Sine03 commented 11 months ago

Issue Description: When attempting to start my Nextron application using the command npm run start, I encountered the following error message:

(node:17096) UnhandledPromiseRejectionWarning: Error: ERR_INVALID_URL (-300) loading 'http://localhost:undefined/home' at rejectAndCleanup (node:electron/js2c/browser_init:2:85498) at WebContents.failListener (node:electron/js2c/browser_init:2:85711) at WebContents emit (node:events:513:28) at WebContents.loadURL (node:electron/js2c/browser_init:2:86705) at BrowserWindow.loadURL (node:electron/js2c/browser_init:2:11321) at C:\Users*\forge\app\background.js:5881:22 (Use electron --trace-warnings ... to show where the warning was created) (node:17096) 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: 1)

Issue Background: I'm using Nextron to build my Electron application, and the error seems to occur during the startup process. It mentions an issue related to an invalid URL with 'http://localhost:undefined/home.' This error prevents the application from launching successfully. Can be find inside of the app/background.js : "http://localhost:undefined/home" folder.

Expected Behavior: The npm run start command should start my Nextron application without encountering this error.

Steps to Reproduce:

Clone the Nextron application. Navigate to the application's directory. Run npm run start in the terminal.

Environment:

Operating System: [WIndows 11] Node.js version: [18.16.0] Nextron version: [v9.x]

bm777 commented 10 months ago

@Sine03 can you post your main/background.js? I'm very sure that you are pushing a undefined value as port to your mainwindow.

const port = process.argv[2]; // <- you might have an issue here
await mainWindow.loadURL(`http://localhost:${port}/main`);