0

I have no idea why this happens, but when I add a static path to my app I get an error on page of a hosting company I am using "nodejitsu" saying that application is not working, the line I am referring to is commented out in a code snippet below 'server.js' that is on the same level as my 'public' directory. I'm trying to think of a work around or other solution to define my public directory, but no luck so far, as I don't understand what could be causing an error. application uses node.js with dependencies including express and socket.io, latest versions.

var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);

server.listen(80);

//app.use(express.static(__dirname + '/public')); 

app.get('/', function(req, res) {
    res.sendFile(__dirname + '/public/index.html');
});

io.on('connection', function (socket) {

});
mscdex
  • 104,356
  • 15
  • 192
  • 153
Ilja
  • 44,142
  • 92
  • 275
  • 498

1 Answers1

1

The express term is not defined because you didn't save it.

You will need to do something like this:

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

app.use(express.static(__dirname + '/public')); 
jfriend00
  • 683,504
  • 96
  • 985
  • 979