I downloaded a node app to test and play around with. I have googled around and found that Express is found to be a little outdated. Can someone help me to fix the implement
I am already using the following snippet and it is working fine:
var express =require("express");
var http = require("http");
var app = express();
//app routers here
...
var httpServer = http.Server(app);
httpServer.listen({PORT}, function(err){
});
var express = require('express');
var app = express();
app.listen(your_port_number);
With the newer release of express (express 4.x), you do not need to create server. app.listen internally does that. Refer https://expressjs.com/en/4x/api.html#app.listen
The solution is given in the error.
Warning: express.createServer() is deprecated, express applications no longer inherit from http.Server please use:
var express = require("express");
var app = express();
So you will have to just do this.
var express = require('express')
, http = require('http');
var app = express();
var server = http.createServer(app);
Another potential solution to this is to install express 2.5.8 as a dependency.
Add to package.json:
{
"name": "authentication"
, "version": "0.0.1"
, "private": true
, "dependencies": {
"express": "2.5.8"
, "jade": ">= 0.26.1"
}
}
and then run
npm install
Its can done with this simple program:
var express = require('express');
var app = express();
app.get('/',
function(req,res)
{
res.send("express");
}
);
app.listen(3333);
it works fine.