[Solved] My application can't connect to my database

I set MONGO_URL at package.json.

  "scripts": {
    "install": "node npm-rebuild.js",
    "meteor": "set MONGO_URL=mongodb://127.0.0.1:27017/test &&meteor --port 3000"
  }

when I run the app ,it always starts a local MongoDB instance and automatically connects to it. It looks like the environment variable I set didnt take effect.
Need to explain , my app is version 1.5 . For some reason ,I couldnt upgrade it . The nodejs version is 14 , npm is 6. I install the latest version of meteor . My server system is centos 7.
As I am a Chinnese developer, the data about meteor in China is very limited. so I hope some kind people can provide advice.Thank you !

Change tha above to:

"start": "MONGO_URL=mongodb://127.0.0.1:27017/test meteor"

and run with: meteor npm start

1 Like

Thank you very much for your reply. But it doesnt seem to be working. I changed it ,and run with :meteor npm start .
2023-04-17_100826

I have solved this problem.
Start meteor:

export MONGO_URL='mongodb://xxx:xxx@xxx:27017/xxx?tls=true&tlsAllowInvalidHostnames=true'
meteor --port  3030

But I wonder why setting MONGO_URL in package.json is invalid. Can someone explain that? Thank you very much .

Hi
it depends on the platform you are using
But if its linux/unix don’t use export and &&
instead use
“MONGO_URL=mongodb://127.0.0.1:27017/test meteor --port 3000”