2

I try to deploy my app into heroku service, but after push the files the log give me this error: Error: Most middleware (like logger) is no longer bundled with Express and must be installed separately.

My package.json is

{
   "dependencies":{
      "connect":"3.0.0-rc.2",
      "express":"^4.1.1",
      "express-logger":"0.0.2",
      "gzippo":"^0.2.0",
      "logfmt":"^1.1.2"
   },
   "devDependencies":{
      "connect":"3.0.0-rc.2",
      "grunt":"~0.4.1",
      "grunt-autoprefixer":"~0.4.0",
      "grunt-bower-install":"~1.0.0",
      "grunt-concurrent":"~0.5.0",
      "grunt-contrib-clean":"~0.5.0",
      "grunt-contrib-compass":"~0.7.2",
      "grunt-contrib-concat":"~0.3.0",
      "grunt-contrib-connect":"~0.5.0",
      "grunt-contrib-copy":"~0.4.1",
      "grunt-contrib-cssmin":"~0.7.0",
      "grunt-contrib-htmlmin":"~0.1.3",
      "grunt-contrib-imagemin":"~0.3.0",
      "grunt-contrib-jshint":"~0.7.1",
      "grunt-contrib-uglify":"~0.2.0",
      "grunt-contrib-watch":"~0.5.2",
      "grunt-google-cdn":"~0.2.0",
      "grunt-karma":"^0.8.3",
      "grunt-newer":"~0.6.1",
      "grunt-ngmin":"~0.0.2",
      "grunt-rev":"~0.1.0",
      "grunt-svgmin":"~0.2.0",
      "grunt-usemin":"~2.0.0",
      "jshint-stylish":"~0.1.3",
      "karma":"^0.12.14",
      "karma-jasmine":"^0.1.5",
      "karma-ng-html2js-preprocessor":"^0.1.0",
      "karma-ng-scenario":"^0.1.0",
      "load-grunt-tasks":"~0.4.0",
      "time-grunt":"~0.2.1"
   },
   "engines":{
      "node":">=0.10.0"
   },
   "name":"eversnap",
   "scripts":{
      "test":"grunt test"
   },
   "version":"0.0.1"
}
Greg
  • 2,163
  • 1
  • 21
  • 23
Tres
  • 571
  • 1
  • 5
  • 19

2 Answers2

9

It looks like Express 4 is upgraded from Express 3 but the json (and maybe code too) is not.

// package.json (Express 4)
...
  "dependencies": {
    "express": "~4.0.0",
    "morgan": "~1.0.0",
    "body-parser": "~1.0.0",
    "method-override": "~1.0.0"
  }
...

sample code (refer to documentation for full details):

// server.js (Express 4)
var express        = require('express');
var morgan         = require('morgan');
var bodyParser     = require('body-parser');
var methodOverride = require('method-override');
var app            = express();
// Replace your Express 3 code, from
//
// app.use(express.logger('dev'));                 
// app.use(express.bodyParser());
// app.use(express.methodOverride()); 
//
// to:
app.use(morgan('dev')); // log every request to the console
app.use(bodyParser()); // pull information from html in POST
app.use(methodOverride());  // simulate DELETE and PUT
app.listen(8080);

Another option is to change the version of express in your package.json to use Express 3 instead, ie.

"express": "~3.0.0"

evandrix
  • 6,041
  • 4
  • 27
  • 38
Ben
  • 5,024
  • 2
  • 18
  • 23
  • Ok, I change like you said, but still not working. But only in heroku, because in localhost it works fine. The error from heroku log is the same – Tres May 07 '14 at 20:47
  • locally, it's using your local copy of express, which might be express 3, not from package.json file – Ben May 07 '14 at 21:04
  • 1
    But, when I try to put "express": "~3.0.0" into package.json the server doesn't start locally – Tres May 07 '14 at 21:06
  • What's the error? Which version do you have locally btw. Use "npm info express" – Ben May 07 '14 at 21:10
  • My local version is 4.1.1 the error is `TypeError: Property 'route' of object function app(req, res){ app.handle(req, res); } is not a function` . I use yeoman angular-fullstack to scaffold the app – Tres May 07 '14 at 21:18
  • Ok, it looks like you're using express 4 locally, I might have to see some of your code to see what you're using that are not currently in package.json – Ben May 07 '14 at 21:26
  • Well, also the standard yeoman scaffolding fail, generating with yo angular-fullstack – Tres May 08 '14 at 16:16
0

I suggest you install the logger package, as it says you should, then use it in your application. I had the same problem but after I installed the required package and used it e.g app.use(logger()) instead of app.use(express-logger())

EnigmaTech
  • 337
  • 5
  • 12