0

Line 3476 of mongo.js located in C:\Users\USERNAME\Documents\meteor\apps\APPNAME.meteor\local\build\programs\server\packages\mongo.js says:

var mongoUrl = process.env.MONGO_URL;

console.log('Connection url => ', process.env.MONGO_URL); on the server prints out

Connection url => mongodb://127.0.0.1:3001/meteor

No where in my windows 10 environment variable name/value is there an entry for MONTO_URL but the there is C:\Program Files\MongoDB\Server\4.2\bin is in the PATH, which indicates a mongodb installed on this windows 10.

mongod is running as a service on this window 10 machine so in the first cmd terminal opened I can type 'mongo' and get the mongo shell,

How can I use this mongo server instead of meteor mongodb?

https://docs.meteor.com/environment-variables.html#MONGO-URL says: MONGO_URL="mongodb://user:password@myserver.com:10139"

Does that mean the following? MONGO_URL="mongodb://windowsUsername:windowsUserPassword@127.0.0.1:27017/my_db_name"

I have a package.json with this entry: "scripts": {"start": "meteor run"} should I change it to

"scripts": {"start": "meteor run", "meteor": "MONGO_URL="mongodb://windowsUsername:windowsUserPassword@127.0.0.1:27017/my_db_name" }

https://docs.npmjs.com/creating-a-package-json-file does not give examples for this case.

What about running the app, the link https://docs.meteor.com/commandline.html#meteorrun says to type meteor which is the same as meteor run, is the script line "start": "meteor run", not needed then?

do I need to worry about npm run meteor as indicated here https://stackoverflow.com/a/35256627/5047454

Thanks

Fred J.
  • 5,759
  • 10
  • 57
  • 106

1 Answers1

0

You need to set the environment variable before starting meteor. If you want to do it using the scripts entry you'd have to put it in the one that starts meteor and then use npm run start:

"scripts": {
  "start": "MONGO_URL=mongodb://windowsUsername:windowsUserPassword@127.0.0.1:27017/my_db_name meteor run"
}

I don't use meteor on windows, so I don't know this first hand, but it seems from this answer that you need to use:

cmd /C "set MONGO_URL=\"mongodb://windowsUsername:windowsUserPassword@127.0.0.1:27017/my_db_name\" && meteor"

I would try to get that to work first, then only once it's working set things up in the scripts in package.json.

Christian Fritz
  • 20,641
  • 3
  • 42
  • 71