Getting a line number for nodejs errors

耗尽温柔 提交于 2019-12-24 17:17:10

问题


I am writing some code to automate a build process using the Grunt task runner and Node. When there is an error while running a task, it gets displayed without line number or file. This makes finding the actual issue a pain.

Example:

$ grunt build Running "build" task Warning: Cannot set property '_appConfig' of undefined Use --force to continue.

Aborted due to warnings.

I am not entirely sure what is responsible for handling these error messages (node, grunt) as I'm quite new to JS development, esp Node. I thus like to know what needs to be changed so I get file and line info together with the errors. Stack traces as a bonus.


回答1:


Try putting

grunt.option('stack', true);

at the top of your gruntfile.



来源:https://stackoverflow.com/questions/19113118/getting-a-line-number-for-nodejs-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!