I researched livereload. The documentation says that after requiring it I should use it as such:
livereload(app)
The example code also shows how it's done
var express = require('express')
....
, livereload = require('express-livereload');
var app = express();
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
.....
});
app.configure('development', function(){
app.use(express.errorHandler());
});
livereload(app)
app.get('/', routes.index);
http.createServer(app).listen(app.get('port'), function(){
console.log("Express server listening on port " + app.get('port'));
});
The thing is I am using the express generator. It as an app.js
file but the file that runs the server is in bin/www
.That file looks like this
var app = require('../app');
var debug = require('debug')('books:server');
var http = require('http');
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
var server = http.createServer(app);
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
...
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
I've removed the error handling methods.
In the above file, I required live reload and tried livereload(app)
as well as livereload(server)
and nothing happened
I did add the relevant script tag in the jade file, and that renders fine.
For now I am hoping to not have to use gulp/grunt. I am in the process of learning those and here I'm just trying to quickly solve this problem without too much configuration (unless there's no way around it)