I want to require a file, written in CoffeeScript in another file also written in CoffeeScript. I want want to require that file again when it changes (using fs.watch()), however as document module.require caches requires.
Is there an easy way to work around this?
Update:
This still doesn't seem to work:
fs.watch './file.coffee', (event, filename) ->
delete require.cache[__dirname + '/' + filename]
require './file'
You can invalidate require cache:
require.cache#Object
Modules are cached in this object when they are required. By deleting a key value from this object, the next require will reload the module.
http://nodejs.org/docs/latest/api/globals.html#require.cache