nodejs mongoose連接mongodb報錯,command find requires authentication

MongoError: command find requires authentication
    at Connection.<anonymous> (/home/Map/node_modules/mongodb-core/lib/connection/pool.js:443:61)
    at Connection.emit (events.js:310:20)
    at processMessage (/home/Map/node_modules/mongodb-core/lib/connection/connection.js:364:10)
    at Socket.<anonymous> (/home/Map/node_modules/mongodb-core/lib/connection/connection.js:533:15)
    at Socket.emit (events.js:310:20)
    at addChunk (_stream_readable.js:286:12)
    at readableAddChunk (_stream_readable.js:268:9)
    at Socket.Readable.push (_stream_readable.js:209:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23) {
  ok: 0,
  errmsg: 'command find requires authentication',
  code: 13,
  codeName: 'Unauthorized',
  operationTime: Timestamp { _bsontype: 'Timestamp', low_: 13, high_: 1617034825 },
  '$clusterTime': {
    clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 13, high_: 1617034825 },
    signature: { hash: [Binary], keyId: [Long] }
  },
  [Symbol(mongoErrorContextSymbol)]: {}
}

 問題:mongoose版本太高了,,在package.json中,將版本改爲 

   "mongoose": "^5.9.7",重新npm i即可
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章