获取nodejs错误的行号 [英] Getting a line number for nodejs errors

查看:483
本文介绍了获取nodejs错误的行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一些代码,使用 Grunt任务转轮 Node 。当运行任务时出现错误,它将显示没有行号或文件。这使得发现实际的问题是一个痛苦。

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.

示例:


$ grunt构建运行构建任务警告:无法设置属性
'_appConfig'未定义使用--force继续。

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

由于警告而中止

我不完全确定负责处理这些错误消息(节点,咕噜)的事情,因为我对JS开发非常新, 。因此,我想知道需要改变什么,所以我得到文件和行信息与错误。堆栈痕迹作为奖励。

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.

推荐答案

尝试放置

grunt.option('stack',true);

在gruntfile的顶部。

at the top of your gruntfile.

这篇关于获取nodejs错误的行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆