问题
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