I've had two problems with now.js that produce this error message. Hopefully one of them will help you.
Circular References
You cannot include any circular references in objects passed into now, or it's extend method will barf. There were some optimizations and workarounds for this and it's now listed as an closed issue, but I have run into it.
initialize() only once
Second, you may not call require('now').initialize(...)
twice or the two instances have a little intellectual conversation and race each other right out of the stack.
What I did instead was to create everyone
in app.js and pass it into all my require(...) methods that need to reference the now "pocket".
In /app.js:
var conf = {
everyone: require('now').initialize(app)
port: 3000,
// etc...
};
require('./routes')(conf)
// etc...
In routes/index.js:
module.exports = function(conf) {
var everyone = conf.everyone;
return {
send: function() {
everyone.now.clientFxn(...);
}
}
}
var http = require('http'); var server = http.createServer(); server.listen(8080); var nowjs = require("now"); var everyone = nowjs.initialize(server);
– Nagana