title: How to run Node.js in localhost?
body: <p>This is my first time to use Node.js and I would like to run it on localhost. I had installed Node.js, but I don't know how to run the localhost.</p>
  
  <p>can you guys help me? Below is my server.js code. </p>
  
  <pre><code>setting_detail = {};
  process.env.NODE_ENV = process.env.NODE_ENV || 'development';
  if (process.env.NODE_ENV == 'production') {
      var cluster = require('cluster');
      if (cluster.isMaster) {
          // Count the machine's CPUs
          var cpuCount = require('os').cpus().length;
  
          // Create a worker for each CPU
          for (var i = 0; i &lt; cpuCount; i += 1) {
              cluster.fork();
          }
  
          // Code to run if we're in a worker process
      } else {
          init();
      }
  } else {
      init();
  }
  
  function init() {
      var port = 5000;
      var config = require('./config/config'),
          mongoose = require('./config/mongoose'),
          express = require('./config/express'),
          db = mongoose(),
          app = express();
  
      app.listen(port);
      var Settings = require('mongoose').model('Settings');
      Settings.findOne({}, function (error, setting) {
          setting_detail = setting
          console.log('Magic happens on port ' + port);
      });
      module.exports = app;
  }
  </code></pre>