I get “Most middleware (like bodyParser) and must be installed separately in nodeJS”
When trying to configure my app, that uses several middlewares, such as body-parser
), I get the following error:
Error: Most middleware (like bodyParser) is no longer bundled with
Express and must be installed separately. Please see
https://github.com/senchalabs/connect#middleware.
I installed body-parser
separately with:
npm i body-parser
My code NodeJS is:
// Server definitions
var express = require('express');
var cors = require('cors');
var bodyParser = require('body-parser');
const neo4j = require('neo4j-driver').v1;
var restify = require('restify');
var expressJwt = require('express-jwt');
var session = require('express-session');
var config = require('./config.json')
var app = express();
var router = express.Router();
var port = 3003;
app.use(restify.plugins.bodyParser());
app.use(express.bodyParser());
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.set('port', process.env.PORT || 3003);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(methodOverride());
app.use(session({ resave: true, saveUninitialized: true, secret: 'uwotm8' }));
// parse application/json
app.use(bodyParser.json());
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// parse multipart/form-data
app.use(multer());
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(bodyParser.json({ type: 'application/vnd.api+json' }))
app.use(cors());
app.use(session({ secret: config.secret, resave: false, saveUninitialized: true }));
var multer = require('multer');
var path = require('path');
var app = express();
var mkdirp = require('mkdirp')
var port = 3003;
var myModule = require('./api-mine-server/api-mine-controller.js');
app.use(express.static(path.join(__dirname, 'uploads')));
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
var storage = multer.diskStorage({
destination: function (req, file, cb) {
//code
});
},
filename: function (req, file, cb) {
cb(null, file.originalname);
}
});
var upload = multer({ storage: storage });
app.post("/upload", upload.array("uploads", 12), function (req, res) {
//code
});
// ----------------- File Uploader code ends -------------------------
app.listen(app.get('port'), function(){
console.log('Express server on port ' + app.get('port'));
});
var server = app.listen(port, function () {
console.log("Listening on port %s...", port);
});
node.js npm
add a comment |
When trying to configure my app, that uses several middlewares, such as body-parser
), I get the following error:
Error: Most middleware (like bodyParser) is no longer bundled with
Express and must be installed separately. Please see
https://github.com/senchalabs/connect#middleware.
I installed body-parser
separately with:
npm i body-parser
My code NodeJS is:
// Server definitions
var express = require('express');
var cors = require('cors');
var bodyParser = require('body-parser');
const neo4j = require('neo4j-driver').v1;
var restify = require('restify');
var expressJwt = require('express-jwt');
var session = require('express-session');
var config = require('./config.json')
var app = express();
var router = express.Router();
var port = 3003;
app.use(restify.plugins.bodyParser());
app.use(express.bodyParser());
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.set('port', process.env.PORT || 3003);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(methodOverride());
app.use(session({ resave: true, saveUninitialized: true, secret: 'uwotm8' }));
// parse application/json
app.use(bodyParser.json());
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// parse multipart/form-data
app.use(multer());
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(bodyParser.json({ type: 'application/vnd.api+json' }))
app.use(cors());
app.use(session({ secret: config.secret, resave: false, saveUninitialized: true }));
var multer = require('multer');
var path = require('path');
var app = express();
var mkdirp = require('mkdirp')
var port = 3003;
var myModule = require('./api-mine-server/api-mine-controller.js');
app.use(express.static(path.join(__dirname, 'uploads')));
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
var storage = multer.diskStorage({
destination: function (req, file, cb) {
//code
});
},
filename: function (req, file, cb) {
cb(null, file.originalname);
}
});
var upload = multer({ storage: storage });
app.post("/upload", upload.array("uploads", 12), function (req, res) {
//code
});
// ----------------- File Uploader code ends -------------------------
app.listen(app.get('port'), function(){
console.log('Express server on port ' + app.get('port'));
});
var server = app.listen(port, function () {
console.log("Listening on port %s...", port);
});
node.js npm
add a comment |
When trying to configure my app, that uses several middlewares, such as body-parser
), I get the following error:
Error: Most middleware (like bodyParser) is no longer bundled with
Express and must be installed separately. Please see
https://github.com/senchalabs/connect#middleware.
I installed body-parser
separately with:
npm i body-parser
My code NodeJS is:
// Server definitions
var express = require('express');
var cors = require('cors');
var bodyParser = require('body-parser');
const neo4j = require('neo4j-driver').v1;
var restify = require('restify');
var expressJwt = require('express-jwt');
var session = require('express-session');
var config = require('./config.json')
var app = express();
var router = express.Router();
var port = 3003;
app.use(restify.plugins.bodyParser());
app.use(express.bodyParser());
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.set('port', process.env.PORT || 3003);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(methodOverride());
app.use(session({ resave: true, saveUninitialized: true, secret: 'uwotm8' }));
// parse application/json
app.use(bodyParser.json());
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// parse multipart/form-data
app.use(multer());
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(bodyParser.json({ type: 'application/vnd.api+json' }))
app.use(cors());
app.use(session({ secret: config.secret, resave: false, saveUninitialized: true }));
var multer = require('multer');
var path = require('path');
var app = express();
var mkdirp = require('mkdirp')
var port = 3003;
var myModule = require('./api-mine-server/api-mine-controller.js');
app.use(express.static(path.join(__dirname, 'uploads')));
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
var storage = multer.diskStorage({
destination: function (req, file, cb) {
//code
});
},
filename: function (req, file, cb) {
cb(null, file.originalname);
}
});
var upload = multer({ storage: storage });
app.post("/upload", upload.array("uploads", 12), function (req, res) {
//code
});
// ----------------- File Uploader code ends -------------------------
app.listen(app.get('port'), function(){
console.log('Express server on port ' + app.get('port'));
});
var server = app.listen(port, function () {
console.log("Listening on port %s...", port);
});
node.js npm
When trying to configure my app, that uses several middlewares, such as body-parser
), I get the following error:
Error: Most middleware (like bodyParser) is no longer bundled with
Express and must be installed separately. Please see
https://github.com/senchalabs/connect#middleware.
I installed body-parser
separately with:
npm i body-parser
My code NodeJS is:
// Server definitions
var express = require('express');
var cors = require('cors');
var bodyParser = require('body-parser');
const neo4j = require('neo4j-driver').v1;
var restify = require('restify');
var expressJwt = require('express-jwt');
var session = require('express-session');
var config = require('./config.json')
var app = express();
var router = express.Router();
var port = 3003;
app.use(restify.plugins.bodyParser());
app.use(express.bodyParser());
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json());
app.set('port', process.env.PORT || 3003);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(methodOverride());
app.use(session({ resave: true, saveUninitialized: true, secret: 'uwotm8' }));
// parse application/json
app.use(bodyParser.json());
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
// parse multipart/form-data
app.use(multer());
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json());
app.use(bodyParser.json({ type: 'application/vnd.api+json' }))
app.use(cors());
app.use(session({ secret: config.secret, resave: false, saveUninitialized: true }));
var multer = require('multer');
var path = require('path');
var app = express();
var mkdirp = require('mkdirp')
var port = 3003;
var myModule = require('./api-mine-server/api-mine-controller.js');
app.use(express.static(path.join(__dirname, 'uploads')));
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
var storage = multer.diskStorage({
destination: function (req, file, cb) {
//code
});
},
filename: function (req, file, cb) {
cb(null, file.originalname);
}
});
var upload = multer({ storage: storage });
app.post("/upload", upload.array("uploads", 12), function (req, res) {
//code
});
// ----------------- File Uploader code ends -------------------------
app.listen(app.get('port'), function(){
console.log('Express server on port ' + app.get('port'));
});
var server = app.listen(port, function () {
console.log("Listening on port %s...", port);
});
node.js npm
node.js npm
edited Nov 20 '18 at 15:47


greuze
2,33332650
2,33332650
asked Nov 20 '18 at 14:23


TechdiveTechdive
21916
21916
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You must remove the line app.use(express.bodyParser());
as it is using the body-parser
from express, and will throw the error
Most middleware (like bodyParser) is no longer bundled with Express
and must be installed separately
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395091%2fi-get-most-middleware-like-bodyparser-and-must-be-installed-separately-in-nod%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You must remove the line app.use(express.bodyParser());
as it is using the body-parser
from express, and will throw the error
Most middleware (like bodyParser) is no longer bundled with Express
and must be installed separately
add a comment |
You must remove the line app.use(express.bodyParser());
as it is using the body-parser
from express, and will throw the error
Most middleware (like bodyParser) is no longer bundled with Express
and must be installed separately
add a comment |
You must remove the line app.use(express.bodyParser());
as it is using the body-parser
from express, and will throw the error
Most middleware (like bodyParser) is no longer bundled with Express
and must be installed separately
You must remove the line app.use(express.bodyParser());
as it is using the body-parser
from express, and will throw the error
Most middleware (like bodyParser) is no longer bundled with Express
and must be installed separately
answered Nov 20 '18 at 15:41


greuzegreuze
2,33332650
2,33332650
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395091%2fi-get-most-middleware-like-bodyparser-and-must-be-installed-separately-in-nod%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown