关于nodejs调试的问题?

遇到下面这种问题应该怎么调试?在调试上有什么技巧?(我看了我index.ejs没发现什么问题啊)

Error
Looks like something broke!

Message:       
Unexpected identifier in "index.ejs"
       
Stack:  
SyntaxError: Unexpected identifier in "index.ejs"
    at Function (native)
    at exports.compile (/home/quoniam/projects/V-club/node_modules/co-ejs/lib/ejs.js:339:15)
    at exports.render (/home/quoniam/projects/V-club/node_modules/co-ejs/lib/ejs.js:381:66)
    at next (native)
    at exports.renderFile (/home/quoniam/projects/V-club/node_modules/co-ejs/lib/ejs.js:412:17)
    at next (native)
    at Object.app.context.render (/home/quoniam/projects/V-club/node_modules/co-ejs/lib/ejs.js:167:23)
    at next (native)
    at onFulfilled (/home/quoniam/projects/V-club/node_modules/koa/node_modules/co/index.js:65:19)
    at process._tickCallback (node.js:356:9)
阅读 4.7k
2 个回答

删掉可能出问题的地方,慢慢排查,我按这种方法找到错误了

主要关注这句:

at Function (native)
    at exports.compile (/home/quoniam/projects/V-club/node_modules/co-ejs/lib/ejs.js:339:15)

把相关的语句一段段删掉再一句一句排查,或者用 Chrome 设置断点也行,总之这样就能找到出错的地方。

... 然而有些 BUG 明知道在那儿但调不好 23333

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题