[英]Error: Cannot find module '@babel/core' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
[英]How to resolve the `at Module._resolveFilename (node:internal/modules/cjs/loader:1039:15)` and server selection error
我一直在尝试使用 nodejs 在本地将数据库连接到 mongodb,但是有一些错误我在这样做时遇到了一些错误。
在我的主文件夹中,只有一个名为db.js
的连接文件,其他文件是package.json
和node_modules
。 这是我在特定位置运行node db.js
后得到的错误,我还使用npm
命令安装了 mongoose。
在使用命令node --trace-deprecation
之后,我得到了以下错误日志。
这是db.js
的代码:-
const mongoose=require('mongoose');
mongoose.connect('mongodb://localhost:27017').then(()=>{
console.log(`conncn established!!\n`);
}).catch((err)=>{
console.log('no connection',err);
})
// module.exports=mongoose;
// "mongodb://localhost:27017/Blogs_db -->it is the connection string for Blogs_db tried to but this //string also but it is not working
我已经检查了我的服务器是否正在运行,并尝试创建新文件夹并再次执行该过程,但它仍然显示连接错误
Go 答案很简单,只需将连接字符串中的本地主机替换为 0.0.0.0 即可,并且有效[这是将上述代码中的本地主机替换为 0.0.0.0 后的 output]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.