使用猫鼬连接mongo db时出现“ TypeError:无法读取未定义的属性'message'”

时间:2019-05-14 15:39:58

标签: node.js mongodb mongoose npm-install

更新npm后,出现此错误。

TypeError: Cannot read property 'message' of undefined . 
    at new MongoError (testuser/node_modules/mongodb-core/lib/error.js:22:23)  
    at new MongoNetworkError (testuser//node_modules/mongodb-core/lib/error.js:60:5) . 
    at TLSSocket.err (testuser//node_modules/mongodb-core/lib/connection/connect.js:287:16) . 
    at Object.onceWrapper (events.js:277:13) . 
    at TLSSocket.emit (events.js:189:13)  
    at TLSSocket.Socket._onTimeout (net.js:440:8) . 
    at ontimeout (timers.js:436:11) . 
    at tryOnTimeout (timers.js:300:5) . 
    at listOnTimeout (timers.js:263:5) . 
    at Timer.processTimers (timers.js:223:10) . 

在连接MongoDB时: 以下是mongo connect代码:

mongoose.connect(Mongo.MONGO_URL, {
  user: Mongo.MONGO_USER,
  pass: Mongo.MONGO_PASSWORD,
  useNewUrlParser: true,
  useCreateIndex: true,
  socketTimeoutMS: 0,
  keepAlive: true,
  reconnectTries: 30
});

0 个答案:

没有答案