Since 0.7... using socketIO *without* using npm / redis no longer possible?
Cannot find module 'redis'
at Function._resolveFilename (module.js:320:11)
at Function._load (module.js:266:25)
at require (module.js:348:19)
at Object.
Please, I don't need or want to deploy Redis or even just a related Node module... we have our own session management worked out just fine. Can we no longer support Socket.IO or is there a workaround I missed?
Redis is absolutely not required, just that the NPM dependency is there for convenience. I'll add a try {} catch {} so that you don't even have to download the submodule, but then again you're gonna have this problem for the other NPM dependencies like the flash policy server.
Solution: use NPM, or download the NPM dependencies.
On Sun, Jul 3, 2011 at 5:06 PM, pearjoint < [email protected]>wrote:
Reply to this email directly or view it on GitHub: https://github.com/LearnBoost/socket.io/issues/333
Guillermo Rauch LearnBoost CTO http://devthought.com
@guille just move require('redis') to the constructor of redis store. It will only be called upon init.
I realize this is a stretch to ask -- since probably 95% of your users are happy NPM users too -- but would you consider changing require() to "tryrequire" (see below) on any "external" (ie. outside of NodeJS base library, socket.io and socket.io-client) requires?
CoffeeScript pseudo-code for the fun of it...
tryrequire: (name) -> try require(name)
or of course the JS equivalent:
tryrequire = function(name) { try { return require(name); } catch (_e) {}}
Please give it some consideration :) due to the nature of our user base there is zero chance of bringing NPM into deployments. Using sockets was an outstanding real-time "poll alternative" to our ajax/json messaging.
3rd-Eden didn't see your reply until after I posted the above. Thanks and hope the suggestion gets picked up =)
@pearjoint I'm totally down for this, my only point was that you still need to download other submodules, it's not just redis that makes the non-npm deployment more time-consuming.
Haven't noticed any -- temporarily added redis just for a quick check to the code-base (but this workaround isn't intended for real deployments down the road) and with redis I no longer get any require() issues and the app at least runs. Haven't tested the new 0.7 socket integration yet though which comes up next. But previously the app didn't even start up due to require(redis).
(node-static, underscore, mongodb, node-uuid are already in the code-base anyway in case it's any of those. flashPolicyServer is set to false since we only support pure native WebSockets if the browser supports them, no legacy workarounds such as Flash / long-polling / iframes -- in this case we fall back to our own interval'ed ajax/poll communication protocol which we reuse via socket.io if enabled at the server-side and supported at the client side)
imho, all optional stuff should be loaded lazily (redis, uglify) and moved out of package.json. The less direct (but may be unused) dependencies, the more orthogonality, hence usability.
Fixed in current master