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即可

浙公网安备 33010602011771号