2
votes
var express = require('express')
    //Required for cluster 
    ,
    cluster = require('cluster')
    //Required for countting the cpu cores 
    ,
    numCPUs = require('os').cpus().length,
    socketio = require('socket.io'),
    routes = require('./routes'),
    user = require('./routes/user'),
    https = require('https'),
    connect = require('connect'),
    fs = require('fs'),
    app = connect(),
    sslOptions, server, port = 1111,
    path = require('path');

var app = module.exports = express.createServer();
app.use(form({
    keepExtensions: true
}));


sslOptions = {
    key: fs.readFileSync('./ssl/server.key'),
    cert: fs.readFileSync('./ssl/server.crt')
};

if (cluster.isMaster) {

    for (var i = 1; i < numCPUs; ++i)
        console.log('hi');
    cluster.fork();
    cluster.on('online', function(worker) {
        console.log("The Master is forked");
    });
    cluster.on('exit', function(worker, code, signal) {
        logger.log('worker ' + worker.process.pid + ' died');
    });
} else {
    var app = express();
    var server = require('https').createServer(app);

    // all environments
    // app.set('port', process.env.PORT || 1111);
    app.set('views', __dirname + '/views');
    app.set('view engine', 'ejs');
    app.use(express.favicon());
    app.use(express.logger('dev'));
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(path.join(__dirname, 'public')));

    // development only
    if ('development' == app.get('env')) {
        app.use(express.errorHandler());
    }

    app.get('/', routes.index);
    app.get('/users', user.list);

    server = https.createServer(sslOptions, app).listen(port, function() {
        console.log('Listening on https://' + server.address().address + ':' + server.address().port);
    });

The error which i am getting is

Warning: express.createServer() is deprecated, express
applications no longer inherit from http.Server,
please use:

  var express = require("express");
  var app = express();


/home/lilac/revanth/app.js:25
app.use(form({ keepExtensions: true }));
        ^
ReferenceError: form is not defined
    at Object. (/home/lilac/revanth/app.js:25:9)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3
1

1 Answers

1
votes

You didn't define the variable form anywhere.

Also you should replace express.createServer() with express()