2011-10-01 98 views
0

我是新來的Node.js,我試圖運行簡單的Node.js代碼。Node.js watchFile錯誤。 「未定義不是函數」

我Node.js的窗戶binary.v0.5.8

這裏是我的js代碼。

var fs = require("fs"); 

fs.readFile('message.text', 'utf8', function (err,data) { 
    if (err) { 
    return console.log(err); 
    } 
    console.log(data); 
}); 

fs.watchFile('message.text',function (curr, prev) { 
    console.log('the current mtime is: ' + curr.mtime); 
    console.log('the previous mtime was: ' + prev.mtime); 
}); 

當我在代碼中只保留readFile時,它會平穩運行。 但在watchfile上給出以下錯誤。

C:\Users\GG\Labs\NodeJS>node.exe test.js 

node.js:208 
     throw e; // process.nextTick error, or 'error' event on first tick 
      ^
TypeError: undefined is not a function 
    at new StatWatcher (fs.js:596:18) 
    at Object.watchFile (fs.js:648:37) 
    at Object.<anonymous> (C:\Users\GG\Labs\NodeJS\test.js:25:4) 
    at Module._compile (module.js:425:26) 
    at Object..js (module.js:443:10) 
    at Module.load (module.js:344:31) 
    at Function._load (module.js:303:12) 
    at Array.<anonymous> (module.js:463:10) 
    at EventEmitter._tickCallback (node.js:200:26) 

任何想法????

回答