how can I track down which module is causing a require.paths error?

科技动态 2018-06-13

I've got a simple coffee script web server set up:

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

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

console.log 'Server running at'

When I run this, it's fine and serving pages:

~/jsfinder> coffee
Server running at

OK no problems there. But when I try the same with nodemon I get:

~/jsfinder> nodemon

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. (/home/user/bin/nodemon@0.6.12: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)

So this is either a bug in nodemon or one of my modules in my npm globals is actually using require.paths. I'm going with the latter. Thing is, I have about 12 modules installed globally, so should I just grep them all and find it that way? Or does that exception stack trace tell me something that I'm not seeing? Does this look like a legit bug in nodemon?

I ran an npm update -g
with no issues this morning, so all my modules should be up to date.

Update: did some grepping in the node modules directory with no results:

/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

So that's telling me that no module in globals or locals is using require.paths. Confusing

Problem courtesy of: jcollum


I would go with the former and would be willing to bet that the error is in nodemon@0.6.12:4:21

I don't think your update command worked, since nodemon
should be @0.6.23

Solution courtesy of: rdrey

Node.js Recipes

责编内容by:Node.js Recipes (源链)。感谢您的支持!


Node.js cant parse a JSON string from base64 decod... I have a string and I want to decode into json. The string was originally base64. Whne I try and dec...
HAP-NodeJS Many home tinkerers will have played with the excellent HAP-NodeJS or (more likely), it’s more si...
NodeJs之数据库异常处理 数据库异常 NodeJs版本:4.4.4 数据库链接错误 使用nodejs处理异常最麻烦不过,这里我抛开nodejs提供的 domain 和一些第三方库专门处理的东西。操作数据库是...
Express / / Node Multiple Applications W... More of a "best practice" question than a technical one, however I'm trying to figure out the best w...
命令行程序是如何工作的 你可能已经知道,在终端里可以调用不同的解释器来执行你的程序,比如: # 执行一段 shell 脚本 sh ./ # 执行一段 node.js 代码 node ./bar.js 下...