mongodb - 连接到 Mongodb 时出现错误
问题描述
这是我在脚本页面中编写的代码
常量猫鼬 = 要求(“猫鼬”);
mongoose.connect("mongodb://localhost:27017/userDB", {useNewUrlParser: true, useUnifiedTopology: true}, function(err){
if(!err){console.log("Connected to Database");}
else{console.log(err);}
});
const userSchema = {
email: String,
password: String
};
const User = new mongoose.model("User", userSchema);
////////////////错误显示在cmd/////////////////
reason:TopologyDescription {
type: 'Single',
setName: null,
maxSetVersion: null,
maxElectionId: null,
servers: Map { 'localhost:27017' => [ServerDescription] },
stale: false,
compatible: true,
compatibilityError: null,
logicalSessionTimeoutMinutes: null,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
commonWireVersion: null
}
}
我在 2000 端口启动了我的本地主机。
解决方案
对于这种问题,我尝试了堆栈溢出和其他一些网站中可用的所有命令,最后我想出了一个解决方案,你必须mongodb
正确重新安装并使用 CMD 删除所有与以下命令相关的文件夹mongodb
,mongoose
然后npm uninstall mongodb --force
重新npm uninstall mongoose --force
启动你的服务器,你们都准备好了。不要忘记删除并重新安装与mongo
项目文件夹中相关的所有文件。
推荐阅读
- javascript - 如何从 Paypal 的按钮捕获并安全地验证付款完成?
- cypher - Cypher:如何使用替代项创建递归成本查询?
- c++ - 将 .csv 文件的整个单元格读入变量
- python - 为带有 javascript 元素的页面编写网络爬虫?
- kubernetes - 无法解码“kubernetes-dashboard.yaml”:没有为版本“rbac.authorization.k8s.io/v1”注册任何类型的“角色”
- django - django dumpdata 命令抛出不存在错误
- r - 一起使用 summarise、cross 和 quantile 函数
- javascript - 未捕获的类型错误:无法读取网球比赛中未定义的属性“宽度”
- r - 使用 group by 聚合 R 中的数据并保留其他非 NA 列的值
- wcf - 向 WCF 添加招摇