Home > Mobile >  'bodyParser' is deprecated in node v14
'bodyParser' is deprecated in node v14

Time:12-12

code :

const express = require("express");
const bodyParser = require("body-parser");

const app = express();
app.use(bodyParser.urlencoded({extended:true}));

app.get("/",function(req,res){
    res.sendFile(__dirname   "/index.html");
})

app.listen(3000,function(){
    console.log("Server started on port 3000");
})

I have installed body-parser with npm i body-parser and required it. But it shows "bodyParser" is deprecated with a crossed line in app.use(bodyParser)

node version : v14.17.1

CodePudding user response:

body-parser is not deprecated in node 14, it's deprecated in Express.

app.use(express.urlencoded({extended: true}));
  • Related