gpt4 book ai didi

node.js - Coffeescript --watch 开关不适用于 Node 0.4.7

转载 作者:太空宇宙 更新时间:2023-11-04 01:16:09 25 4
gpt4 key购买 nike

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com