0

I am new to NodeJS and I can't not run the old project. Here is error message...

Error: Most middleware (like compress) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.

And Here is code of server.js

/*** Module dependencies.*/
/*jshint loopfunc: true */
var express = require('express'),
    fs = require('fs'),
    passport = require('passport'),
    logger = require('mean-logger');

//Load configurations

var env = process.env.NODE_ENV = process.env.NODE_ENV || 'development',
    config = require('./config/config'),
    auth = require('./config/middlewares/authorization'),
    mongoose = require('mongoose');

//Bootstrap db connection
var db = mongoose.connect(config.db);
var register_models = require('./app/register_models');
register_models();


//Bootstrap models
var models_path = __dirname + '/app/models';
var walk = function(path) {
    fs.readdirSync(path).forEach(function(file) {
        var newPath = path + '/' + file;
        var stat = fs.statSync(newPath);
        if (stat.isFile()) {
            if (/(.*)\.(js|coffee)/.test(file)) {
                require(newPath);
            }
        } else if (stat.isDirectory()) {
            walk(newPath);
        }
    });
};
walk(models_path);

//bootstrap passport config
require('./config/passport')(passport);


var app = express();


//express settings
require('./config/express')(app, passport, db);

//Bootstrap routes
require('./config/routes')(app, passport, auth);

//Start the app by listening on <port>
var port = process.env.PORT || config.port;
app.listen(port);
console.log('Express app started on port ' + port);

//Initializing logger
logger.init(app, passport, mongoose);

//expose app
exports = module.exports = app;
1
  • You have updated your express to version 4 which had breaking changes. Check the guide on their site on how to upgrade from 3.0 to 4.0 Commented Jan 22, 2015 at 9:55

1 Answer 1

3

It's because of express 4.x.x, If your run npm install command and package.json in your project folder has a dependency like "express": "^4.10.6" or "express": "*", which in turn will install latest version of express. It (express 4.x.x) will not let your old app (written in express 3.x.x or < version) run.

This problem can be solved by either installing express < 4.x.x for example:

npm install [email protected]

or by installing each missing module that logged in node console (exactly like your above mentioned missings)

or here is nice article to follow migration from express 3.x.x to 4.x.x

Migration Article

Happy Helping!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.