search

Home  >  Q&A  >  body text

node.js - How to start Mongodb in node code?

Everything I found on the Internet was how to connect Mongodb, but I didn’t see how to start it.

Does everyone manually start Mondodb when developing locally, and then open a command line to perform other operations?

For example, is there any method or plug-in that can directly specify the port to start Mongodb in app.js? I have just started to contact these, and I hope you can give me some advice.

女神的闺蜜爱上我女神的闺蜜爱上我2748 days ago794

reply all(3)I'll reply

  • typecho

    typecho2017-06-10 09:50:07

    ... you mongo. . Why use node to start. . You need to use mongodb to manually start the mongo service. . . The node program is only responsible for connecting to mongo

    reply
    0
  • 巴扎黑

    巴扎黑2017-06-10 09:50:07

    In the scripts section of package.json, add the relevant scripts:

    https://docs.npmjs.com/misc/s...

    You can take a look at prestart/poststop.

    Love MongoDB! Have fun!

    reply
    0
  • 某草草

    某草草2017-06-10 09:50:07

    The questioner probably wants to start mongo directly in the code, using npm scripts in
    package.json

    {
    "start:mongo":"Start mongo's bash"
    }

    reply
    0
  • Cancelreply