2012-08-09 14 views
0

我有一個簡單的咖啡腳本的Web服務器設置:如何追蹤哪個模塊導致require.paths錯誤?

http = require 'http' 
express = require 'express' 

http.createServer (req, res) -> 
     res.writeHead 200 
     res.end 'Hello, World!' 
.listen 8888 

console.log 'Server running at http://127.0.0.1:8888/' 

當我運行它,它的優良和服務網頁:

~/jsfinder> coffee app.coffee 
Server running at http://127.0.0.1:8888/ 

OK沒有問題存在。但是,當我嘗試用相同的我nodemon得到:

~/jsfinder> nodemon app.coffee 

Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead. 
    at Function.Module._compile.Object.defineProperty.get (module.js:386:11) 
    at Object.<anonymous> (/home/user/bin/[email protected]:4:21) 
    at Module._compile (module.js:449:26) 
    at Object.Module._extensions..js (module.js:467:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:312:12) 
    at Module.runMain (module.js:492:10) 
    at process.startup.processNextTick.process._tickCallback (node.js:244:9) 

因此,這是無論是在nodemon或錯誤實際上是用require.paths在我的NPM全局我的模塊之一。我正在與後者。事情是,我在全球範圍內安裝了大約12個模塊,所以我應該全心全意地找到並找到它?或者那個異常堆棧跟蹤告訴我一些我沒有看到的東西?這看起來像是nodemon中的一個合法bug嗎?

我跑了一個npm update -g今天早上沒有問題,所以我所有的模塊應該是最新的。

更新:做了一些grepping在節點模塊目錄沒有結果:

/usr/lib/nodejs/npm/node_modules> find . -type f -print0 | xargs -0 grep require.paths 
/usr/lib/nodejs/npm/node_modules> cd .. 
/usr/lib/nodejs/npm> find . -type f -print0 | xargs -0 grep require.paths 
/usr/lib/nodejs/npm> cd .. 
/usr/lib/nodejs> find . -type f -print0 | xargs -0 grep require.paths 
./module.js: throw new Error('require.paths is removed. Use ' + 

和:

~/jsfinder> find . -type f -print0 | xargs -0 grep require.paths 
~/jsfinder> 

所以這是在告訴我,在全局或當地人沒有模塊是使用require.paths 。 混淆

+0

如果您使用純Node.js(沒有CoffeeScript)做同樣的示例,它是否工作? – 2012-08-09 15:23:02

+0

@HectorCorrea nope,我嘗試了hello world的節點版本並得到了相同的結果。 – jcollum 2012-08-10 03:23:18

回答

1

我會去與前者並願意打賭,誤差在[email protected]:4:21 :)

我不認爲你的update命令的工作,因爲nodemon應該是@0.6.23

+0

對不起,我的壞消息是文本已經過期。複製之後,我做了全局更新,然後重新運行應用程序並得到相同的結果。 – jcollum 2012-08-10 01:33:21

+0

請用新的堆棧跟蹤更新問題! – rdrey 2012-08-10 09:09:02

+0

我會,但我99%確定棧跟蹤是相同的,除了版本號。 – jcollum 2012-08-10 20:23:44