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

有帮助吗?

解决方案

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);

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top