neutralinojs / neutralinojs-cli

neu cli for Neutralinojs
https://neutralino.js.org/docs/cli/neu-cli
MIT License
91 stars 56 forks source link

Detecting Vite dev server doesn't work on Windows 11 #225

Closed jouni-kantola closed 8 months ago

jouni-kantola commented 8 months ago

neu CLI doesn't detect that Vite is up and running on Windows 11. It works fine on MacOS (version 11).

This is the log that is displayed:

  VITE v4.5.0  ready in 387 ms

  ➜  Local:   http://localhost:3000/
  ➜  Network: use --host to expose
  ➜  press h to show help
neu: INFO App will be launched when http://localhost:3000 is ready...
neu: INFO App will be launched when http://localhost:3000 is ready...
[...]
neu: ERRR Timeout exceeded while waiting till local TCP port: 3000

This is the neutralino.config.js I use to start Vite:

"frontendLibrary": {
    "patchFile": "/resources/index.html",
    "devUrl": "http://localhost:3000",
    "projectPath": "/",
    "devCommand": "vite",
    "buildCommand": "vue-tsc --noEmit && vite build"
}

Output from npx @neutralinojs/neu version:

--- Global ---
neu CLI: v10.0.0

--- Project: mobtimer (js.neutralino.mobtimer) ---
Neutralinojs binaries: v4.14.1
Neutralinojs client: v3.12.0
Project version: v2.6.0

Is this a bug or are there any Vite setups to compare with that works on both MacOS and Windows?

jouni-kantola commented 8 months ago

I tested the tcp-port-used npm module that is used for checking the devUrl by starting Vite manually on port 4000 and then running the following script:

const tcpPortUsed = require("tcp-port-used");

tcpPortUsed.check(4000, "127.0.0.1").then(
  function (inUse) {
    console.log("Port 4000 usage:", inUse);
  },
  function (err) {
    console.error("Error on check:", err.message);
  }
);

The result is that tcp-port-used reports the port being unused.

Port 4000 usage: false
jouni-kantola commented 8 months ago

I found a workaround. If I start Vite with vite --host the waitUntilUsed reports the correct port state.

Working frontendLibrary config:

"frontendLibrary": {
    "patchFile": "/resources/index.html",
    "devUrl": "http://localhost:3000",
    "projectPath": "/",
    "devCommand": "vite --host",
    "buildCommand": "vue-tsc --noEmit && vite build"
}
jouni-kantola commented 8 months ago

I'll close this issue as there is now a described workaround by using vite --host.

shalithasuranga commented 8 months ago

Hey @jouni-kantola thanks for posting the solution for this issue :)