I am learning MEAN stack so started with Node.js and Express first. I run Nginx on Windows 10. I installed the latest Node. NPM version is 3.10.3, Node version is 6.7.0, and Express version is 4.14.0. I did npm install express --save, npm install mongoose --save, npm install body-parser --save, and created the server.js file. I did node server on my sources and I got the following error:
C:\nginx\html>node server
C:\nginx\html\server.js:7
app.get('/', function(req, res){
^
TypeError: app.get is not a function
at Object. (C:\nginx\html\server.js:7:5)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.runMain (module.js:590:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
C:\nginx\html>
And the code in my server.js file is:
var express = require('express');
var express = require('mongoose');
var express = require('body-parser');
var app = express();
app.get('/', function(req, res){
res.send('hello world');
});
app.listen(80);
I am not sure how a hello world application can go wrong. I saw a lot of tuts and code with the same thing but working for them. Even the Express's official hello world app has same code.