相关疑难解决方法(0)

警告:在循环依赖中访问模块导出的不存在的属性“MongoError”

我正在使用节点进行 API 并使用 Mongoose。当我yarn dev启动我的 Nodemon 时,Mongo 出现错误,我不知道如何解决这个问题。有人会有什么想法吗?(我正在使用 MongoDB Atlas 数据库)

在以下错误之后。

yarn run v1.22.5
$ nodemon src/server.js
[nodemon] 2.0.7
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node src/server.js`
(node:752) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:752) DeprecationWarning: Listening to events on the Db class has been deprecated and will be …
Run Code Online (Sandbox Code Playgroud)

api mongoose mongodb node.js nodemon

60
推荐指数
6
解决办法
6万
查看次数

由于 URI 错误,无法连接到 MongoDB

我试图在节点服务器上从 MongoDB运行 mongoDB 完整代码

我的 mongo 版本:4.4.3

节点版本:v15.7.0

我从 MongoDB 导入了入门代码,代码如下:

const { MongoClient } = require("mongodb");
// Connection URI
const uri =
  "mongodb+srv://sample-hostname:27017/?poolSize=20&writeConcern=majority";
// Create a new MongoClient
const client = new MongoClient(uri);
async function run() {
  try {
    // Connect the client to the server
    await client.connect();
    // Establish and verify connection
    await client.db("admin").command({ ping: 1 });
    console.log("Connected successfully to server");
  } finally {
    // Ensures that the client will close when you finish/error
    await …
Run Code Online (Sandbox Code Playgroud)

javascript circular-dependency mongodb node.js

24
推荐指数
3
解决办法
2万
查看次数

如何在 MongoDB 中删除此弃用警告以及为什么会发生这种情况?

我只是想创建一个 API 并在我的 app.js 文件中连接到它,但每次运行 app.js 时我都会收到此弃用警告。我已经检查了 mongoose 和 MongoDB 中的所有弃用警告,但我找不到任何与我匹配的警告。我得到的警告是,

(node:16864) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency

(Use node --trace-warnings ... to show where the warning was created)

(node:16864) DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version.

为什么我会收到此弃用警告以及如何将其删除?

rest mongoose mongodb

21
推荐指数
1
解决办法
5204
查看次数