node.js - 运行 GeddyJS 时如何为 node.js 启用 --debug

标签 node.js

GeddyJS 通过从项目根目录运行 geddy 来启动。

我在获取 GeddyJS 时遇到一些问题在启用调试的 Node.js 下运行。

getty 安装/usr/local/bin/geddy:

#!/usr/bin/env node
...

我快速复制了它,并修改了 shebang 行:

#!/usr/bin/env node --debug
...

但这不起作用,因为 env 找不到“node --debug”。

然后我尝试编写一个包装脚本来充当 shebang 行中的解释器:

#!/bin/sh
exec /usr/bin/env node --debug $@

这一次, Node 在启用调试器的情况下启动,但路径必须困惑,或者环境必须不同,因为我遇到了丢失模块异常:

$ geddy-debug
debugger listening on port 5858

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: Cannot find module '../lib/geddy'
    at Function._resolveFilename (module.js:332:11)
    at Function._load (module.js:279:25)
    at Module.require (module.js:354:17)
    at require (module.js:370:17)
    at Object. (/usr/local/bin/geddy-debug:4:1)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:479:10)

如果我不尝试启用调试,这当然可以正常工作。

我想在 Eclipse 中调试:https://github.com/joyent/node/wiki/Using-Eclipse-as-Node-Applications-Debugger ,仅与 node --debug scriptname.js

配合使用效果很好

如有任何建议,我们将不胜感激。

最佳答案

回答我自己的问题,这样其他人如果碰巧看到这个就能受益:

从项目目录中,覆盖 shebang 行并直接调用解释器来运行geddy 脚本:

/usr/bin/env Node --debug/usr/local/bin/geddy

关于node.js - 运行 GeddyJS 时如何为 node.js 启用 --debug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9449773/

相关文章:

node.js - Node.js 中的 http Web 服务器需要什么中间件?

node.js - 未调用Nodejs Passport身份验证回调

node.js - 凭据错误 : Missing credentials in config in nodejs aws-sdk

java - dynjs 与 Node 上 javascript 中字符串函数的性能比较

javascript - `npm audit` 不断返回 "Your configured registry (https://registry.npmjs.org/) does not support audit requests."。我如何让它再次工作?

node.js - 监听 POST 请求、解析服务器、node.js

node.js - 使用 Redis 存储扩展 Engine.IO(与 Socket.IO 相比)

node.js - 如何使用Nginx通过express router加载页面

node.js - 我应该如何在redis中存储数组?

mysql - 如果我想优先显示某些条件,如何在 Sequelize for MySQL 中排序?