Detecting Vite dev server doesn't work on Windows 11
Closed this issue · 4 comments
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?
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
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"
}
I'll close this issue as there is now a described workaround by using vite --host
.
Hey @jouni-kantola thanks for posting the solution for this issue :)