[nodejs] Disabling module caching

711 views
Skip to first unread message

Konstantin Käfer

unread,
May 2, 2010, 11:37:58 AM5/2/10
to nod...@googlegroups.com
Hi,

I want to disable module caching during development and experimented with various ways of hot code loading and file watching (e.g. see http://pastie.textmate.org/private/awhq8uaqadfsdkwtagow) which adds some complexity.

I found that just adding `delete module.moduleCache[module.id];` to the top of the file that shouldn’t be cached does the trick. Is that the recommended way of disabling the cache for a module? Are there better ways (note that I’m only interested in code reloading for development, not for production use).

Kind Regards,
Konstantin

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.

Isaac Schlueter

unread,
May 2, 2010, 3:07:37 PM5/2/10
to nod...@googlegroups.com
You should also add delete module.moduleCache[__filename] to be
forward-compatible.

You said that this is only for development, and that's great. But
seriously, don't do stuff like this for production. The caching is
there for a reason, and it's very easy to accidentally get infinite
require() loops.

--i

2010/5/2 Konstantin Käfer <kka...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages