了解node.js错误消息

时间:2016-05-08 07:28:55

标签: node.js

Error initializing middleware
SyntaxError: Unexpected token ILLEGAL
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.cls_wrapMethod [as _load] node_modules/newrelic/lib/shimmer.js:246:38)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> api/services/chargeService.js:3:23)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
at Function.cls_wrapMethod [as _load] node_modules/newrelic/lib/shimmer.js:246:38)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)

意外的令牌ILLEGAL似乎我写错了或忘了在我的一个源文件中注释掉一行。但错误信息非常无益。

是否有用于解析此类消息的通用工具?

1 个答案:

答案 0 :(得分:0)

这是callstack

select 'SELECT Q1 as '||MAX(CASE WHEN t2.ref_value = 'Q1' THEN t2.actual_value END)||',
               Q2 as '||MAX(CASE WHEN t2.ref_value = 'Q2' THEN t2.actual_value END)||',
               Q3 as '||MAX(CASE WHEN t2.ref_value = 'Q3' THEN t2.actual_value END)
        ||'FROM Table1'
FROM Table1 t1
INNER JOIN Table2 ON(1=1)

通常节点脚本和npm包不会抛出意外的异常,它们都有测试,所以首先你必须检查你的文件

Error initializing middleware                    <== graceful error message
SyntaxError: Unexpected token ILLEGAL            <== raw error message
    at exports.runInThisContext (vm.js:53:16)    <== YOUR SCRIPT, CHECK HERE
    at Module._compile (module.js:387:25)        <== node script
    at Object.Module._extensions.js (module.js)  <== node script
    at Module.load (module.js:357:32)            <== node script
    at Function.Module._load (module.js:314:12)  <== node script
    at Function.cls node_modules/.../shimmer.js) <== package script
    at Module.require (module.js:367:17)         <== node script
    at require (internal/module.js:20:19)        <== node script
    at Object.<anonymous> api/services/chargeService.js:3:23) <== YOUR SCRIPT, CHECK HERE
    at Module._compile (module.js:413:34)        <== node script, etc
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
at Function.cls_wrapMethod [as _load] node_modules/newrelic/lib/shimmer.js:246:38)
at Module.require (module.js:367:17)
at require (internal/module.js:20:19)

这意味着文件at exports.runInThisContext (vm.js:53:16) 中的exports.runInThisContext函数先前已执行异常捕获

vm.js

与上面相同,在异常捕获之前,在第3行第23行的文件at Object.<anonymous> api/services/chargeService.js:3:23) 中执行了对象getter或setter