I'm trying to build my first node.js application, but, running using node server.js
I get the following error message :
connect: multipart: use parser (multiparty, busboy, formidable) directly connect: limit: Restrict request size at location of read
as shown by this screenshot:
snippet of code in which I'm using connect
:
var connect = require('connect'),
express = require('express');
var app = express();
app.use(connect.cookieParser())
.use(connect.session({secret: 'app_1'}))
.use(connect.bodyParser())
How to fix this, please? Thanks a lot!
connect
is deprecated since express.js
version 4. Try installing the middleware (1, 2, 3) separately like this:
$ npm install cookie-parser --save
$ npm install body-parser --save
$ npm install cookie-session --save
And in your code:
var express = require('express');
var app = express();
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var cookieSession = require('cookie-session');
app.use(cookieParser());
app.use(bodyParser());
app.use(cookieSession({secret: 'app_1'}));
replace
.use(connect.bodyParser())
into
.use(express.urlencoded()); .use(express.json());
source https://github.com/visionmedia/express/issues/1793
edit: full code
var connect = require('connect'),
express = require('express');
var app = express();
app.use(connect.cookieParser()) // i use express.cookieParser, but connect.cookieParser should also work
.use(express.urlencoded());
.use(express.json());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With