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

1K
Visualizações
MongoParseError: options poolsize, usenewurlparse are not supported

I get the error "MongoParseError: options poolsize, usenewurlparse are not supported" when I run "nodemon server".

Here the code for setting up the mongodb connection:

import app from "./server.js"
import mongodb from "mongodb"
import dotenv from "dotenv"

dotenv.config()
const MongoClient = mongodb.MongoClient

const port = process.env.PORT || 8000

MongoClient.connect(
  process.env.RESTREVIEWS_DB_URI,
  {
    poolSize: 50,
    wtimeout: 2500,
    useNewUrlParse: true,
    }
  )
  .catch(err => {
   
    console.error(err.stack)
    process.exit(1)
  })
  .then(async client => {
   
    app.listen(port, () => {
      console.log(`listening on port ${port}`)
    })
  })
over 4 years ago · Santiago Trujillo
7 Respostas
Responde à pergunta

0

use this configuration for mongoose

const express = require('express');
const mongoose = require('mongoose');

mongoose.Promise = global.Promise;
mongoose.set('useNewUrlParser', true);
mongoose.set('useFindAndModify', false);
mongoose.set('useCreateIndex', true);
mongoose.set('useUnifiedTopology', true);
mongoose.connect(your mongodb URI).then(()=> {
    app.listen(PORT, () => {
        console.log(`Listening on port` + PORT);
    })
}).catch((e) => {console.log(e)})

and app.listen is not an asynchronous function you don't need to use async for that

over 4 years ago · Santiago Trujillo Relatório

0

Some of the MongoClient options have been deprecated.

MongoClient.connect(
    process.env.RESTREVIEWS_DB_URI,
    {
        maxPoolSize: 50, 
        wtimeoutMS: 2500,
        useNewUrlParser: true
    }

).catch(err => {
    console.error(err.stack)
    process.exit(1)
}
over 4 years ago · Santiago Trujillo Relatório

0

The version stopped supporting poolsize,wtimeout and useNewUrlParse.Replace your code with my edit.

import app from "./server.js";
import mongodb from "mongodb"
import dotenv from "dotenv"
dotenv.config()
const MongoClient = mongodb.MongoClient

const port = process.env.PORT || 8000

MongoClient.connect(
    process.env.RESTREVIEWS_DB_URI,
    {
        maxPoolSize:50,
        wtimeoutMS:2500,
        useNewUrlParser:true
    }
)
.catch(err => {
    console.error(err.stack)
    process.exit(1)
})
.then(async client => {
    app.listen(port, () => {
        console.log('listening on port '+port)
    })
})
over 4 years ago · Santiago Trujillo Relatório

0

const mongoose = require('mongoose');
require('dotenv').config();
const user = process.env.mongoUser;
const pass = process.env.mongoPass;
const url = `mongodb+srv://${user}:${pass}@cluster0.asqnt.mongodb.net/MyDB`;

mongoose.connect(url, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    useCreateIndex: true
})
.then(console.log('connecting'))
.catch(err => console.log(`error: ${err}`))
over 4 years ago · Santiago Trujillo Relatório

0

I was just now trying to get the server up when I noticed that:

{
   useNewUrlParser: true,
   useUnifieldTopology: true,
   useFindAndModify: false
}

They have been deprecated. And looking at this publication the one that has worked is the one from @Jinoy Varghese. I leave you the my code of the mongol congiguration to connect the database.

const mongoose = require('mongoose')
require('dotenv').config({ path: '.env' })

const connectDB = async () => {
    try {
        await mongoose.connect(process.env.DB_MONGO, {
            maxPoolSize: 50,
            wtimeoutMS: 2500,
            useNewUrlParser: true
        })
        console.log('DB connected ')
    } catch (err) {
        console.log(err)
        process.exit(1)
    }
}
module.exports = connectDB
over 4 years ago · Santiago Trujillo Relatório

0

After changes in MongoDB-native diver to 4.x, you need to just change MongoClientOptions interface:

you have this:

MongoClient.connect(
  process.env.RESTREVIEWS_DB_URI,
  {
    poolSize: 50, // maxPoolSize
    wtimeout: 2500, // wtimeoutMS
    useNewUrlParse: true, // feel free to remove, no longer used by the driver.
    }
  )

you need:

MongoClient.connect(
  process.env.RESTREVIEWS_DB_URI,
  {
    maxPoolSize: 50,
    wtimeoutMS: 2500,
  }
)
over 4 years ago · Santiago Trujillo Relatório

0

I had the same issue and this is how I managed, in your code , replace

 {
    poolSize: 50,
    wtimeout: 2500,
    useNewUrlParse: true,
    }

with

{
  
  maxPoolSize: 50,
  wtimeoutMS: 2500,
  useNewUrlParser: true,
}
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