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

105
Visualizações
code that I entered for the backend developing using mern stack for my web application

I got an error when I run the code.Is there any errors in my code? This is the code that I enterd.

 const express = require("express");
const mongoose= require("mongoose");
const bodyParser = require("body-parser");
const cors = require("cors");
const dotenv=require("dotenv");
const app = express();
require("dotenv").config();

const PORT =process.env.PORT || 8070;

app.use(cors());
app.use(bodyParser.json());

const URL = process.env.MONGODB_URL;

mongoose.connect(URL, {
    useCreateIndex: true,
    useNewUrlParser:true,
    useUnifieldTopologyL:true,
    useFindAndModify:false,
});

const connection = mongoose.connection;
connection.once("open", () => {
    console.log("Mongodb Connection success!");
})

app.listen(PORT, () => {
    console.log('Server is up and running on port number: ${PORT}')
})

i got this error when I give npm start command

backend@1.0.0 start C:\Users\Admin\Desktop\cosmetic\backend node server.js

Server is up and running on port number: ${PORT} (node:4808) UnhandledPromiseRejectionWarning: MongoParseError: options usecreateindex, useunifieldtopologyl, usefindandmodify are not supported at Object.parseOptions (C:\Users\Admin\Desktop\cosmetic\backend\node_modules\mongodb\lib\connection_string.js:281:15) at new MongoClient (C:\Users\Admin\Desktop\cosmetic\backend\node_modules\mongodb\lib\mongo_client.js:62:46) at C:\Users\Admin\Desktop\cosmetic\backend\node_modules\mongoose\lib\connection.js:781:16 at new Promise () at NativeConnection.Connection.openUri (C:\Users\Admin\Desktop\cosmetic\backend\node_modules\mongoose\lib\connection.js:778:19) at C:\Users\Admin\Desktop\cosmetic\backend\node_modules\mongoose\lib\index.js:330:10 at C:\Users\Admin\Desktop\cosmetic\backend\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5 at new Promise () at promiseOrCallback (C:\Users\Admin\Desktop\cosmetic\backend\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10) at Mongoose._promiseOrCallback (C:\Users\Admin\Desktop\cosmetic\backend\node_modules\mongoose\lib\index.js:1151:10) (Use node --trace-warnings ... to show where the warning was created) (node:4808) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:4808) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The error is pretty straight forward, from Mongoose 6.0 docs:

useNewUrlParser, useUnifiedTopology, useFindAndModify, and useCreateIndex are no longer supported options. Mongoose 6 always behaves as if useNewUrlParser, useUnifiedTopology, and useCreateIndex are true, and useFindAndModify is false. Please remove these options from your code.

These options are no longer supported and you should remove them from the options you're passing to the mongoose connect function.

about 4 years ago · Juan Pablo Isaza 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