views:

223

answers:

2

I'm trying to setup my own nodejs server, but I'm having a problem. I can't figure out how to see my edited files without restarting nodejs. Is there a way to edit file live with nodejs?

+3  A: 

Check out node-supervisor. You can give it a collection of files to watch for changes, and it restarts your server if any of them change. It also restarts it if it crashes for some other reason.

http://github.com/isaacs/node-supervisor

"Hot-swapping" code is not enabled in NodeJS because it is so easy to accidentally end up with memory leaks or multiple copies of objects that aren't being garbage collected. Node is about making your programs accidentally fast, not accidentally leaky.

isaacs
+3  A: 

Nodules is a module loader for Node that handles auto-reloading of modules without restarting the server (since that is what you were asking about):

http://github.com/kriszyp/nodules

Nodules does intelligent dependency tracking so the appropriate module factories are re-executed to preserve correct references when modules are reloaded without requiring a full restart.

Kris Zyp