75

I'm a node.js developer who creates web apps using express.js. By now, my problem is:

Whenever I create an app on my computer, npm install its stuff and run it (with node app.js and nodemon) I get this message in the console:

connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
Express server listening on port 3000

The app works, that's fine. But when I clone an app created in other computer I don't get that message, so I'm supposing I have something outdated in my computer.

I went to the site mentioned in the message and confirmed my speculations. That is a deprecation warning. However, I've updated node and npm and globally express but I still getting the note.

My problem is therefore: I don't know what do I need to update in order to get rid of the deprecation notes because they're freaking me out.

1

3 Answers 3

170

This is a warning that will go away once Express updates to use Connect 3.0 - as a temporary fix, follow the instructions at the top of https://github.com/senchalabs/connect/wiki/Connect-3.0. Specifically, find this line in your app:

app.use(express.bodyParser());

And replace it with the following (this is what bodyParser will be in 3.0):

app.use(express.json());
app.use(express.urlencoded());
4
  • 1
    more information on the connect 3.0 issue here: groups.google.com/d/msg/express-js/iP2VyhkypHo/5AXQiYN3RPcJ Nov 7, 2013 at 10:15
  • 16
    I also needed to add app.use(express.multipart()) because my multipart forms stopped working (of course), which also brought back the deprecation warning (of course). Nov 22, 2013 at 3:08
  • 5
    use one of the multipart parsers listed in the wiki. don't use connect/express' Dec 16, 2013 at 11:30
  • 1
    THANK! YOU! I was about to go crazy Feb 12, 2014 at 16:18
60
+50

i'm responsible for this deprecation notice. did you read the wiki? https://github.com/senchalabs/connect/wiki/Connect-3.0

step 1: use each parser directly instead of app.use(express.bodyParser());

app.use(express.json());
app.use(express.urlencoded());

step 2: use a different multipart parser, for e.g: connect-multiparty can be used

app.use(require('connect-multiparty')())

work on connect 3 and express 4 hasn't begun yet because node 0.12 is taking a while to be released. there's nothing to update, yet.

6
  • 1
    It's not a deprecation notice -- it's a breaking change. app.use(express.bodyParser) doesn't work anymore with the latest version but the major version numbers haven't changed for the libs, which breaks the concept of semver.
    – tkone
    Dec 23, 2013 at 16:22
  • running the latest version from npm install express, and doing a very simple: var express = require('express'), app = express(); app.use(express.bodyParser); app.get('/', function(req,res){ res.send(200, 'ok');}); app.listen(3000);. Making a request to http://localhost:3000/ hangs curl & browser & prints warning. Removing app.use(express.bodyParser) or switching to app.use(express.json()) causes app to return "ok" with HTTP Status 200.
    – tkone
    Dec 23, 2013 at 20:50
  • It's connect-multiparty, instead of connect-multipart
    – Vince Yuan
    Mar 11, 2014 at 16:39
  • 1
    I wish there was an option to suppress this warning; while deprecation notices are important it's very rare in the enterprise environment to NOT have an option to suppress them. My current situation has me unable to make the necessary changes to avoid the message for at least 6 months but a configuration option I could but now we have these sprinkled throughout our logs in a different format than anything else making our older log parsers not very happy. Just food for thought; deprecation notices are important but devs need a way to get them out of the way if necessary.
    – Kris
    Mar 22, 2014 at 7:26
  • 1
    @Kris if you can't use the json and urlencoded middleware directly (presumably since you're using the multipart support to handle file uploads) you can momentarily override console.log while the bodyParser is instantiated, then bring it back. I used this approach for a period of time in Sails to normalize our log output May 9, 2014 at 1:34
1

since express is just a wrapper to connect, i suggest using connect directly.

so instead of: app.use(express.bodyParser());

use:

connect = require('connect');
app.use(connect.json());
app.use(connect.urlencoded());

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.