javascript - Node.js: cannot call method 'use' of undefined -
i'm trying learn node.js , i'm getting error.
app.use(morgan('dev')); //log request console typeerror: cannot call method 'use' of undefined @ object.<anonymous> (/root/authproject/server.js:21:5) @ module._compile (module.js:456:26) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ function.module._load (module.js:312:12) @ function.module.runmain (module.js:497:10) @ startup (node.js:119:16) @ node.js:901:3
what causing it?
you're going need code setup express:
var express = require('express'); var app = express();
and you'll need import morgan
similarly. i'm presume you're copying code somewhere - perhaps it's not complete example?
Comments
Post a Comment