socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

Since 0.7... using socketIO *without* using npm / redis no longer possible?

Open pearjoint opened this issue 15 years ago • 8 comments

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. (/home/username/projectname/node_modules/socket.io/lib/stores/redis.js:15:13) at Module._compile (module.js:404:26) at Object..js (module.js:410:10) at Module.load (module.js:336:31) at Function._load (module.js:297:12) at require (module.js:348:19) at Object. (/home/username/projectname/node_modules/socket.io/lib/socket.io.js:117:22)

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?

pearjoint avatar Jul 03 '11 20:07 pearjoint

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

rauchg avatar Jul 03 '11 20:07 rauchg

@guille just move require('redis') to the constructor of redis store. It will only be called upon init.

3rd-Eden avatar Jul 03 '11 20:07 3rd-Eden

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.

pearjoint avatar Jul 03 '11 20:07 pearjoint

3rd-Eden didn't see your reply until after I posted the above. Thanks and hope the suggestion gets picked up =)

pearjoint avatar Jul 03 '11 20:07 pearjoint

@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.

rauchg avatar Jul 03 '11 20:07 rauchg

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)

pearjoint avatar Jul 03 '11 21:07 pearjoint

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.

dvv avatar Jul 04 '11 05:07 dvv

Fixed in current master

3rd-Eden avatar Aug 03 '11 19:08 3rd-Eden