V
V
VoisHunter2019-05-13 13:21:14
MongoDB
VoisHunter, 2019-05-13 13:21:14

How to solve project startup error?

Error when launching www.js

(node:10102) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
Redis connected.
Unable to connect to the mongoDb: { MongoError: Authentication failed.
    at Function._getError (/var/www/html/languagelab/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js:125:14)
    at sendAuthCommand (/var/www/html/languagelab/node_modules/mongoose/node_modules/mongodb-core/lib/auth/scram.js:175:31)
    at Connection.messageHandler (/var/www/html/languagelab/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connect.js:334:5)
    at emitTwo (events.js:126:13)
    at Connection.emit (events.js:214:7)
    at processMessage (/var/www/html/languagelab/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:364:10)
    at Socket.<anonymous> (/var/www/html/languagelab/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:533:15)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:601:20) name: 'MongoError', [Symbol(mongoErrorContextSymbol)]: {} }

I read that you need to write {useNewUrlParser: true }, but I don't understand where to write...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2019-05-13
@VoisHunter

write in mongo database connection string
https://stackoverflow.com/a/51182415
If you are using version >= 3.1.0 change you mongo connection file to ->
MongoClient.connect("mongodb://localhost:27017/YourDB", { useNewUrlParser: true })
or your mongoose connection file to ->
mongoose. connect("mongodb://localhost:27017/YourDB", { useNewUrlParser: true });
but here the error "MongoError: Authentication failed." falls out, that is, is the path to the database correctly written? or the username or password does not match

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question