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


3d WebGL Browser Game #4: Continuous Delivery One of the many advantages of building for the web is the ease of deployment and distribution. A user just needs a hyper...
网件R7800 NAS搭建 本文主要记录了如何通过R7800的ESATA口外接一个机械硬盘(50MB/s读写),在路由器上搭建NAS。 I. 硬盘挂载 驱动安装: opkg install kmod-usb-ohci opkg inst...
浅析node.js的模块加载 在node.js中,模块使用CommonJS规范,一个文件是一个模块 node.js中的模块可分为三类 内部模块 - node.js提供的模块如 fs,http,path等 自定模块 - 我们自己写的模块 ...
NodeJS: Serving dynamic files I've been used to PHP, where code is put in a file, and executed each time on load. With NodeJS, I need to use HTML ...
How Fintonic uses Node.js, MongoDB & Kubernete... At RisingStack, we are highly interested in building scalable and resilient software architectures. We know that a lot o...