npm express “hello world” middleware error

后端 未结 4 1169

node --version v0.10.26

npm --version 1.4.3

I followed this: http://expressjs.com/guide.html

which has this code

    var express = re         


        
4条回答
  •  花落未央
    2021-01-04 15:37

    The first line tells it all:

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

    Looking at https://github.com/senchalabs/connect#middleware we can see that express.logger has been replaced with morgan.

    var logger = require('morgan');
    app.use(logger); //replaces your app.use(express.logger());
    

    Remember to npm install morgan and/or add it to your package.json

提交回复
热议问题