Grayson Grayson - 1 month ago 10
Node.js Question

Express suddenly doesn't include any middleware

I've been using Node.js and Express for a while perfectly fine for a web application, and suddenly today I keep getting errors about how "Most middleware (like bodyParser) is no longer bundled with Express and must be installed separately"

This is happening because I upgraded npm to 4.0.2 and there is a link in the error dialog documenting how to install and use the new middleware.

Error: Most middleware (like bodyParser) is no longer bundled with Express and must be installed separately. Please see
at Function.get (/Users/Grayson/max_performance_survey_report_v1.5/node_modules/express/lib/express.js:99:13)
at Object.<anonymous> (/Users/Grayson/max_performance_survey_report_v1.5/server.js:27:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)

Edit: I understand how to run with the new versions of express, and how to install the new middleware. I think it would be useful to put down on record how exactly to revert back to the old version of express/npm so that people can if they want to.

rsp rsp

You need to either add the missing middleware to package.json - you even got a URL in your error message where you can find more info:

Or alternatively you can use an older version of Express in your package.json if it works fine for you.

Take a look at the package.json file from one of my projects on GitHub:

It includes:

"dependencies": {
  "express": "^4.14.0"

You can set some exact version there:

"dependencies": {
  "express": "2.0.0"

and npm install would only try to download that specific version. Just find out what was the last version that your application is compatible with and set it there.

Using Travis plus Greenkeeper could help you a lot with testing your code with various versions of your dependencies.