coffeescript 编译器的 --watch 指令不适用于 node.js 0.4.7。如何修复?
(目前在 Heroku 上部署需要 Node 0.4.7。)
最佳答案
node.js 0.4.7 中没有 fs.watch 方法。将 command.js 中第 198 行的 watch 函数替换为以下内容:
watch = function(source, base) {
return fs.stat(source, function(err, prevStats) {
if (err) throw err;
return fs.watchFile(source, function(curr, prev) {
return fs.stat(source, function(err, stats) {
if (err) throw err;
if (stats.size === prevStats.size && stats.mtime.getTime() === prevStats.mtime.getTime()) {
return;
}
prevStats = stats;
return fs.readFile(source, function(err, code) {
if (err) throw err;
return compileScript(source, code.toString(), base);
});
});
});
});
};
关于node.js - Coffeescript --watch 开关不适用于 Node 0.4.7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8119066/