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 http://127.0.0.1:8888/'

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

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

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

~/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. (/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 ' +

And:

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

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

Problem courtesy of: jcollum

Solution

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阅读原文】。感谢您的支持!

您可能感兴趣的

Generate random strings using Regular Expressions ... There are times when you need to generate random strings in your application. Maybe it is to fill a database table or an array for testing various alg...
#217: See Module Dependency Trees in Your Browser ... Robert Kieffer NPMGraph: See Module Dependency Trees in Your Browser Enter an npm module name and this tool renders an interactive dependen...
add data to pre-existing csv file via nodejs and y... I was hoping someone could shed some light on this for me... I can't for the life of me work out how to append data using nodejs and ya-csv...
@Jeans_philippes Head here to learn how you can be... If you have found what you believe to be an issue with Node.js please do not hesitate to file an issue on the GitHub project. Please include ...
node.js and mongodb-native: wait till a collection... I am using node.js and with the native mongodb driver (node-mongodb-native); My current project uses node.js + now.js + mongo-db. The...