【发布时间】:2021-11-03 06:20:54
【问题描述】:
我是 MERN 堆栈的新手,遇到了这个错误。
[nodemon] restarting due to changes...
[nodemon] starting `node index.js`
bad auth : Authentication failed.
这是我的代码,我尝试更改密码,但无济于事
import express from "express";
import bodyParser from "body-parser";
import mongoose from "mongoose";
import cors from "cors";
const app = express();
app.use(bodyParser.json({ limit: "30mb", extended: true }));
app.use(bodyParser.urlencoded({ limit: "30mb", extended: true }));
app.use(cors());
const CONNETCION_URL =
"mongodb+srv://myratcharyyev:<password>@cluster0.mn9xi.mongodb.net/myFirstDatabase?retryWrites=true&w=majority";
const PORT = process.env.PORT || 5000;
mongoose
.connect(CONNETCION_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() =>
app.listen([PORT, () => console.log(`Server running on port : ${PORT}`)])
)
.catch((error) => console.log(error.message));
// mongoose.set("useFindAndModify", false);
【问题讨论】:
-
您是否在 Mongo Atlas 设置中开放了从任何地方访问(IP 白名单)?
-
是的,还是同样的错误。
标签: node.js reactjs mongoose mern nodemon