Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

424
Visualizações
Cannot connect to MongoDB because of wrong URI

I was trying to run mongoDB on node server Full Code here from MongoDB:

My mongo version: 4.4.3

Node version: v15.7.0

I've imported get started code from MongoDB, and here's the code:

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 client.close();
  }
}
run().catch(console.dir);

On terminal, when i run "node app.js", it throws me following error:

> (node:79653) Warning: Accessing non-existent property 'MongoError' of
> module exports inside circular dependency (Use `node --trace-warnings
> ...` to show where the warning was created) MongoParseError: URI does
> not have hostname, domain name and tld
>     at parseSrvConnectionString (/home/harmony/Desktop/FruitsProject/node_modules/mongodb/lib/core/uri_parser.js:50:21)
>     at parseConnectionString (/home/harmony/Desktop/FruitsProject/node_modules/mongodb/lib/core/uri_parser.js:594:12)
>     at connect (/home/harmony/Desktop/FruitsProject/node_modules/mongodb/lib/operations/connect.js:284:3)
>     at /home/harmony/Desktop/FruitsProject/node_modules/mongodb/lib/mongo_client.js:225:5
>     at maybePromise (/home/harmony/Desktop/FruitsProject/node_modules/mongodb/lib/utils.js:681:3)
>     at MongoClient.connect (/home/harmony/Desktop/FruitsProject/node_modules/mongodb/lib/mongo_client.js:221:10)
>     at run (/home/harmony/Desktop/FruitsProject/app.js:12:18)
>     at Object.<anonymous> (/home/harmony/Desktop/FruitsProject/app.js:21:1)
over 4 years ago · Santiago Trujillo
6 Respostas
Responde à pergunta

0

The error Accessing non-existent property 'MongoError' of > module exports inside circular dependency is caused by a bug in mongodb 3.6.4

It's already reported here

Back to version 3.6.3 works for me:

npm uninstall mongodb --save

Install version 3.6.3

npm i mongodb@3.6.3
over 4 years ago · Santiago Trujillo Relatório

0

For everyone searching about this warning, don't worry, it's just a version bug, and was already reported. Just uninstall the 3.6.4 version and install the version 3.6.3 as answered on @kmgt answer.

More details:
https://developer.mongodb.com/community/forums/t/warning-accessing-non-existent-property-mongoerror-of-module-exports-inside-circular-dependency/15411

https://github.com/Automattic/mongoose/issues/9900

over 4 years ago · Santiago Trujillo Relatório

0

I downgraded MongoDB as recommended but that alone didn’t solve the problem.

I had to downgrade mongoose too to get the error removed.

I downgraded to:

MongoDB version 3.6.3 Mongoose version 5.11.15

over 4 years ago · Santiago Trujillo Relatório

0

You don't have to downgrade your MongoDB, just downgrade your mongoose package to 5.11.15 as in this mention: https://github.com/Automattic/mongoose/issues/9900#issuecomment-778535254 I'm using Mongo v4.4.3 and just downgrade mongoose worked for me.

over 4 years ago · Santiago Trujillo Relatório

0

I have a similar error too, am running on MacOS Catelina:

(node:3265) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency (Use `node --trace-warnings ...` to show where the warning was created) Server started on port 3000

Previously running on:

node: v14.15.4, mongodb: v4.4.3, mongoose: v5.11.18

After downgrading mongoose to v5.11.15, the error is gone.

  1. Uninstall mongoose from terminal
    npm uninstall mongoose

  2. Install mongoose version 5.11.15
    npm i mongoose@5.11.15

over 4 years ago · Santiago Trujillo Relatório

0

[mongo error 1

because of the line which I show in red rectangler over the picture

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda