Node.js 如何使用Grunt报告节点js的错误

Node.js 如何使用Grunt报告节点js的错误,node.js,express,gruntjs,Node.js,Express,Gruntjs,我的问题是如何让grunt像默认的节点启动脚本一样报告错误。在我最新的node/express项目中,我尝试使用Grunt任务管理器,并将开始脚本从 "start": "node ./bin/www" 到 问题是,当我运行“npm start”或“grunt”时,错误报告是不够的 [nodemon]app crashed - waiting for file changes before starting //error reported by grunt 当我将开始脚本更改回“node

我的问题是如何让grunt像默认的节点启动脚本一样报告错误。在我最新的node/express项目中,我尝试使用Grunt任务管理器,并将开始脚本从

"start": "node ./bin/www"

问题是,当我运行“npm start”或“grunt”时,错误报告是不够的

[nodemon]app crashed - waiting for file changes before starting   //error reported by grunt
当我将开始脚本更改回“node./bin/www”时,我可以看到如下错误

Error: Cannot find module mongoose   //error reported by node
这表明我忘记了npm安装mongoose。那么我怎样才能让Grunt报告这个错误呢

编辑:节点报告的另一个错误示例

 MissingSchemaError: Schema hasnt been registed for model "Admin"   //error reported by node
编辑2:grunfile.js配置如下

/**** other configurations to minify and uglify ****/

nodemon: {
  dev: {
    script: 'server.js'
  }
},

// run watch and nodemon at the same time
concurrent: {
  options: {
    logConcurrentOutput: true
  },
  tasks: ['nodemon', 'watch']
}   
grunt.loadNpmTasks('grunt-nodemon');
grunt.loadNpmTasks('grunt-concurrent');

有两种方法可以实现这一点:

  • 您可以在命令行上指定
    --stack
    选项:

    "start": "grunt --stack"
    
  • 您可以在
    grunfile.js
    中启用
    stack
    选项:

    grunt.option("stack", true);
    

有两种方法可以实现这一点:

  • 您可以在命令行上指定
    --stack
    选项:

    "start": "grunt --stack"
    
  • 您可以在
    grunfile.js
    中启用
    stack
    选项:

    grunt.option("stack", true);
    

--由于某种原因,堆栈不会报告错误。它只是说“应用程序崩溃--在启动前等待文件更改”,然后是运行
nodemon
的grunt任务捕获并报告错误。您需要在问题中包含所述任务的配置。我编辑问题是为了显示与nodemon相关的grunfile.js。--由于某种原因,stack不会报告错误。它只是说“应用程序崩溃--在启动前等待文件更改”,然后是运行
nodemon
的grunt任务捕获并报告错误。您需要在问题中包含所述任务的配置。我编辑了该问题以显示与nodemon相关的grunfile.js。