Cannot start meteor@3.0.4 on windows

Hi guys

So I installed the latest meteor 3.0.4 from scrach (uninstall and reinstall using npx meteor) on windows 11 and started a brand new project using the meteor create command and I did install all the packages using meteor npm i

Whenever I try to start the app with meteor run I will get these errors:

Unexpected mongo exit code 1. Restarting.
Unexpected mongo exit code 1. Restarting.     
Unexpected mongo exit code 1. Restarting.
Can't start Mongo server.
MongoDB failed global initialization

And then the program just stops running.
There is no log related to mongodb anywhere I could search for.
There are no files in the .meteor/local/db folder. The db folder has the right write permission but I try to run the program as administrator and that didn’t help either.
I searched for the issue online and I found that there could be issues related to the language environmental values but that is related to linux and I’m running windows 11 and there my languge settings are all set in the windows settings to english.

I did try to downgrade meteor to 2.16 and start a new project with that version and that app starts up just fine with mongodb, so the issue is related to meteor 3.0.4 and windows. I also tried the new 3.1.0-beta.1 version but that doesn’t work either.

Anybody had the same issue when using meteor 3?

Have you tried WSL? I believe it’s the best approach to use Meteor on Windows right now

Hey I am really glad you have this problem. Let me explain :)))).

I don’t know why you have it (I will follow with a meme anyway) but I wanted to suggest an alternative.

I am on OSX (mac) and I have a Mongo server running on the station at all times. I connect all my local projects to this server and this is what I get in MongoDB Compass. Regardless whether a project is running or not I get to see the full document models (schema) and documents for all my project at all times. Those items in the list are equivalent to the clusters I keep in Mongo Atlas. I expanded one of them so you can see the collections under a DB.
I keep some scripts as well and can dump live data into any of those DB instantly, in case I need to simulate something from live.

The meme I was going to follow with anyway. The sound is viral on Insta but I will give you the original
Development on Windows: https://www.youtube.com/watch?v=wLg04uu2j2o

No I haven’t tried WSL yet. The meteor 3 docs doesn’t state that I have to use WSL and because I’ve never had any problem running meter on windows before I didn’t think it cannot run it anymore.

I guess running a separate mongo instance and make meteor connect to it might solve the problem like paulishca recommended it in a strange way but obviously that makes the whole starting up a development environment more difficult.

If this is the case currently then the meteor 3 docs should clearly state that this version in not compatible with windows anymore and explain the workaround for it.

Using an external MongoDB instance would definitely help.

Another option is to run the Meteor app with admin privileges. Windows often has permission issues that can limit resource access and slow performance due to security checks. Could you try this?

Regarding WSL, I highly recommend it. I’ve been using it for years, and its IDE integration is great. Although it’s not yet documented officially in Meteor docs, WSL has proven effective for creating a UNIX-like environment on Windows, supporting Meteor development while maintaining performance. We may provide more details in the future, but it’s already straightforward to set up.

I suggested that because it makes everything a lot easier. You just need to understand how it makes it easier. The only change for your Meteor project is to add MONGO_URL=mongodb://127.0.0.1:27017/your_db_name in from of your Meteor command or set it as an env var.

1 Like

Yes I did try running it as administrator and also with disabled microsoft defender, but no luck.

I’m just saying that if we need a linux environment to effectively start meteor then we shouldn’t state that it can be installed on windows because it’s not true even if it’s WSL. For new devs this error will discourage the use of meteor and we don’t have any explanation or even an error log that a saparate mongodb instance needs to be set up or they’ll need to have a linux environment for this.

Windows support is available for Meteor, and we’ve worked hard to address specific env issues raised in Meteor 3. The issue you’re encountering appears new, likely related to differences in your Windows environment, or meteor installation.

As showed in the next picture, Meteor, including the built-in Mongo, runs without issues on my Windows setup (no WSL).

Have you tried fully clearing the cache in .meteor/local to eliminate any cache inconsistencies? Then try to run it again. (This will clear your mongodb data be aware of it)

Additionally, to ensure any new fixes are applied and prevent old code from causing issues, consider fully reinstalling Meteor. You can try running npx meteor uninstall followed by npx meteor.

Using WSL or an external MongoDB is a suggested workaround to address your issue and get you unblocked. In the meantime we’re actively working to resolve Windows-specific bugs, as outlined in our changelog, and we will need additional assistance in reproducing issues for the proper fixing.

As you mentioned, it’s hard to catch the exact cause without additional logging. If the suggestions above don’t resolve your issue, I will consider further debugging to gather more details on your problem. Then we can collect as much information as possible to help you and other Windows user facing the same problem.

Okay that is a good sign because at least we know it’s working on some windows machines.

I tried clearing the cache in local but I also reinstalled the full project multiple times using the meteor create command. Also reinstalled meteor multiple times using different methods. Also mongodb starts up fine using the mongod command, but it’s a different instance than the built in mongo in meteor.

Do you know if there is any way to display the logs from the built in mongodb so I can check for the errors?

Debugging this isn’t straightforward, but you can debug by running your app from a local checkout. Here’s how:

  1. Clone the Meteor project: git clone https://github.com/meteor/meteor.git
  2. Switch to the branch matching your Meteor version (currently, 3.0.4 is on the devel branch). Alternatively, locate the correct commit of the Meteor version under the tags section: git checkout a7c8f3e63e8403bd2d16004c5d6f670ea9d7293b
  3. Edit tools/runners/run-mongo.js to add the next code that logs to a file by handling the spawning Mongod process. Use --logpath option as part of mongod process doesn’t work, since Meteor tool require to listen the process.stdout to start the app.
// Import dependencies used
const path = require("path");
const fs = require("fs");

// mongo spawn at tools/runners/run-mongo.js#L527
proc = spawnMongod(mongod_path, port, dbPath, replSetName); 

// Add this code to simulatanously write on process.stdout and log file
const logFilePath = path.join(process.cwd(), 'mongod.log');
const logFileStream = fs.createWriteStream(logFilePath, { flags: 'a' });

proc.stdout.on('data', (data) => {
  process.stdout.write(data);
  logFileStream.write(data);
});

proc.stderr.on('data', (data) => {
  process.stderr.write(data);
  logFileStream.write(data);
});
  1. Run your app from the meteor checkout: <path-to-meteor-checkout>/meteor run.

This will create a log at ./mongod.log root of your app folder where you can check for any errors related to the built-in mongo of your app. Please share the logs with us to help diagnose and resolve the issue.

We will plan to add a feature for enabling built-in MongoDB logging in future releases.

Thank you @nachocodoner
With this debugging added I managed to find the issue. It was a space character in my dev folder’s name.
Apparently the project folder that mongodb wants to use is not inside " characters and that breaks the path if there is a space character in the folder name. Obviously this is not an issue on linux.

It would be awesome if this logging could be turned into a feature flag or something.

:tada:

Yeah, definitely we need that. I made a note.

Thanks for your report

1 Like