2011-03-08 84 views
1

我試圖用Cygwin運行a simple node.js webserver。我在installing node之後將the file複製到test.js之後,這就是我所得到的結果。Node.JS錯誤:找不到模塊'posix'(使用Cygwin)

$ node test.js 

node.js:116 
     throw e; // process.nextTick error, or 'error' event on first tick 
     ^
Error: Cannot find module 'posix' 
    at Function._resolveFilename (module.js:299:11) 
    at Function._load (module.js:245:25) 
    at require (module.js:327:19) 
    at Object.<anonymous> (/home/me/test.js:27:13) 
    at Module._compile (module.js:383:26) 
    at Object..js (module.js:389:10) 
    at Module.load (module.js:315:31) 
    at Function._load (module.js:276:12) 
    at Array.<anonymous> (module.js:402:10) 
    at EventEmitter._tickCallback (node.js:108:26) 

[email protected] ~ 
$ 

回答

3

您安裝了哪個版本的節點?如果您看看node change log,require('posix')已移入require('fs')中的API版本0.1.29(2010.02.17)。要點很古老。

0

我更新了代碼,以最新的node.js構建在這裏:https://gist.github.com/862132仍然我建議找到其他更新的示例,因爲此代碼不是很好(特別是在我更新它之後)。

+0

我認爲它在100行代碼下的任何web服務器將是一個很好的起點。如果你拿出評論並刪除一些空行,這個例子完全適合。 – 2011-03-09 13:49:37

+0

對不起,我錯誤地刪除了要點,稍後我會再次上傳。 – 2011-04-28 11:10:14