0

I´m trying to get nowjs to work with expressjs 3.0alpha4. I´ve added the script to my view like so:

<script src="/nowjs/now.js"></script>

And have also tried:

<script src="https://localhost/nowjs/now.js"></script>

But all i get is a:

GET https://localhost/nowjs/now.js 403 (Forbidden)

Have anyone gotten this to work with expressjs 3.0.?

Even if i host the now.js file, I still get: Now is not defined

georgesamper
  • 4,989
  • 5
  • 40
  • 59
  • Your question isn't really related to nowjs. It's more a 'My static file isn't getting served by Express' question. – Pickels May 28 '12 at 15:58

2 Answers2

2

You need to pass an HTTPServer object to the now initializer. Express 3.0 doesn't reveal this object like 2.x did.

So do something like:

var server = http.createServer(app).listen(app.get('port'), function() {
  console.log('Express server listening on port ' + app.get('port'));
}

var everyone = require('now').initialize(server);
SirensOfTitan
  • 799
  • 1
  • 7
  • 19
0

First check if you have your static middleware setup.

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

Second make sure you put your nowjs directory inside the public directory with the now.js file inside the nowjs directory.

Pickels
  • 33,902
  • 26
  • 118
  • 178
  • Well it's not that. As I wrote in the question, even if I host the file now.js (now should actually do that automatically so you don't have to), i get a: `Now is not defined`. I now know that when you require express, it's actually a function rather than a server, as of 3.0. So in for example socket.io you cant't pass express to listen(), you have to pass the http server instead. I'm looking in the code for now to see where that is. – georgesamper May 28 '12 at 17:51