mongoose.connect(), first argument should be String, received undefined

前端 未结 21 2915
既然无缘
既然无缘 2021-02-12 15:55

I am trying to set the test database for the testing purpose, but its not working.

I am trying to connect to mongodb using mongoose, but finding problem in connection er

21条回答
  •  粉色の甜心
    2021-02-12 16:31

    If we don't want to define the path of the .env file like this,

    require('dotenv').config({ path: 'ENV_FILENAME' });
    

    we can place .env file in the same place as our main file, which was App.js in my case. So we could directly write

    require('dotenv').config()
    

提交回复
热议问题