Run multiple meteor-vite projects error

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.

What errors are you getting? And how are you running your apps?

Try also to specify the ROOT_URL if you’re not doing that:

ROOT_URL=http://localhost:3000 meteor

You can also try to use the --port flag to run multiple apps at once:

$: ROOT_URL=http://localhost:3000 meteor --port 3000

$: ROOT_URL=http://localhost:5000 meteor --port 5000

os: macOS 14.6.1
mongodb: mongodb-community 6.0.16
test project: clone meteor-vite/examples/meteor-v3-vue at release · JorgenVatle/meteor-vite · GitHub, 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!

Sorry, I do not see the error.

The only difference I see between apps 1 and 2 is that in app 2, you get the message Port 5173 is in use, trying another one..., and your local changes to http://localhost:5174/. But both apps are up and running on http://localhost:3000/ and http://localhost:4000/.

No error for the log, but http://localhost:3000/ and http://localhost:4000/ will both display the second running app with browser.