Coffeescript和节点主管在一起?

Nil*_*ils 5 node.js coffeescript

我正在使用带有--watch选项的coffeescript来重建对.coffee文件的更改的javascript.

将它与node-supervisor结合起来在更改编译的javascript时重新启动Node是否安全?

我担心当coffeescript重新编译多个文件时,由于原子性,它不会很强大.node-supervisor可以跳过枪并在检测到第一个文件系统更改时重新启动Node.它是否足够强大,以便在忙于重新启动Node时实现其他更改?

有没有更好的办法?理想情况下,我只有一个文件系统观察程序重新编译我的coffeescript并重新启动节点.

Lem*_*ing 7

创建一个JavaScript启动器run.js,就像这样:

require('coffee-script');
require('./launch');
Run Code Online (Sandbox Code Playgroud)

然后使用supervisor和相应的选项运行此文件:

supervisor -e "node|js|coffee" run.js
Run Code Online (Sandbox Code Playgroud)

这在Windows上对我很有用.


ale*_*lex 6

你可以使用nodemon,它甚至有一个延迟功能(在经过几秒后重启服务器),例如:

nodemon --debug ./server.coffee 80
Run Code Online (Sandbox Code Playgroud)

nodemon的另一个好功能是忽略文件,例如:

# this is my ignore file with a nice comment at the top

/vendor/*     # ignore all external submodules
/public/*     # static files
./README.md   # a specific file
*.css         # ignore any CSS files too
Run Code Online (Sandbox Code Playgroud)

除此之外,请阅读github repo上的文档并观看有关nodemon的Nodetuts视频:http://nodetuts.com/tutorials/14-some-nodejs-tools.html