JorgenVatle / meteor-vite

⚡ Replace Meteor's bundler with Vite for blazing fast build-times
MIT License
32 stars 10 forks source link

Run multiple Meteor-vite error #186

Closed SvenWangChina closed 1 month ago

SvenWangChina commented 3 months ago

When running multiple Meteor projects, only one can be displayed normally in the browser. Setting different server.port and server.hmr.port in vite.config.js does not work too.

SvenWangChina commented 3 months ago

os: macOS 14.6.1 mongodb: mongodb-community 6.0.16 test project: clone https://github.com/JorgenVatle/meteor-vite/tree/release/examples/meteor-v3-vue, and update to Meteor 3.0.2, modify imports/ui/App.vue different for testing. nodejs: v20.15.1

The apps work fine with following command:

meteor --port 3000
meteor --port 4000

The apps display bug with following command:

MONGO_URL=mongodb://127.0.0.1:27017/app meteor --port 3000
MONGO_URL=mongodb://127.0.0.1:27017/app meteor --port 4000

I set MONGO_URL env variable will invoke this bug, even I set env with export MONGO_URL=mongodb://127.0.0.1:27017/app

I got the following info when run first app:

I20240821-09:37:40.564(8)? ⚡   Starting Vite server...
W20240821-09:37:40.571(8)? (STDERR) ⚡  You are using an out of date version of `meteor-vite`.
W20240821-09:37:40.572(8)? (STDERR)    Please update it: $ meteor npm i meteor-vite@1.10.3
I20240821-09:37:40.686(8)? Greetings from /server/main.ts!
I20240821-09:37:40.686(8)? Meteor server started up successfully: http://localhost:3000/
=> Started your app.

=> App running at: http://localhost:3000/
I20240821-09:37:41.060(8)?   ➜  Local:   http://localhost:5173/
I20240821-09:37:41.061(8)?   ➜  Network: use --host to expose
I20240821-09:37:41.064(8)? ⚡   Meteor-Vite ready for connections!

This for run second app:

I20240821-09:37:42.030(8)? ⚡   Starting Vite server...
W20240821-09:37:42.036(8)? (STDERR) ⚡  You are using an out of date version of `meteor-vite`.
W20240821-09:37:42.036(8)? (STDERR)    Please update it: $ meteor npm i meteor-vite@1.10.3
I20240821-09:37:42.145(8)? Greetings from /server/main.ts!
I20240821-09:37:42.145(8)? Meteor server started up successfully: http://localhost:4000/
=> Started your app.

=> App running at: http://localhost:4000/
I20240821-09:37:42.521(8)? Port 5173 is in use, trying another one...
I20240821-09:37:42.524(8)?   ➜  Local:   http://localhost:5174/
I20240821-09:37:42.524(8)?   ➜  Network: use --host to expose
I20240821-09:37:42.527(8)? ⚡   Meteor-Vite ready for connections!
JorgenVatle commented 2 months ago

Oh, that's strange. Meteor-Vite should gracefully handle port conflicts when running multiple apps with conflicting ports. Meteor and Vite dev servers do run independently however. Usually Vite goes for 5173 and changes to a new port if it's not available.

Would you be able to share some snippets of the logs that show up in your browser's developer console for each app?

If you can provide your current versions of jorgenvatle:vite-bundler and meteor-vite that would be helpful as well. 😁

JorgenVatle commented 1 month ago

Fixed in #192