【问题标题】:What does the 2nd number after the colon in a node.js stack trace line mean?node.js 堆栈跟踪行中冒号后的第二个数字是什么意思?
【发布时间】:2013-04-28 06:54:24
【问题描述】:

在 node.js 堆栈跟踪中总是有两个数字,行号然后是 : 和另一个数字。在下面的示例中,第一行 faye-redis.js:153:36 和 153 是该文件中发生错误的行号,但是数字 :36 是什么意思?

node_modules/faye-redis/faye-redis.js:153:36 • publish.notify
node_modules/faye-redis/faye-redis.js:72:16 • clientExists
node_modules/redis/index.js:532:9 • try_callback
node_modules/redis/index.js:614:13 • return_reply
node_modules/redis/index.js:266:14 • RedisClient.init_parser
events.js:96:17 • EventEmitter.emit
node_modules/redis/lib/parser/hiredis.js:43:18 • execute
node_modules/redis/index.js:488:27 • on_data
node_modules/redis/index.js:82:14 • none
events.js:96:17 • EventEmitter.emit
net.js:397:14 • onread

【问题讨论】:

    标签: javascript node.js coffeescript


    【解决方案1】:

    第一个数字是行(行号),第二个是列(行上的字符)。在 Javascript 中,许多编码人员习惯性地将大量代码用闭包等嵌套在一行中,或者使用像 YUI 压缩器这样的压缩器,因此它通常是相当相关的信息。

    【讨论】:

    • 不仅是 JavaScript,还有许多其他语言。 line:column 约定在堆栈跟踪中很常见。
    • 一个问题:如果您使用制表符进行缩进,编辑器报告的列号可能与报告的字符数不匹配。例如,Sublime Text 将我的选项卡报告为每列两列。
    猜你喜欢
    • 2011-01-06
    • 2015-05-14
    • 1970-01-01
    • 2020-06-26
    • 1970-01-01
    • 1970-01-01
    • 2011-09-13
    • 2019-06-30
    相关资源
    最近更新 更多