我试图用Intellij(IDEA)调试grunt。 这些技术是:NodeJS,express,AngularJS。
问题: 调试器不会在断点处停止。
我很高兴听到你的想法。
配置选项卡:
节点解释器:C:\ Program Files \ nodejs \ node.exe
Javscript文件:C:\ Users [user] \ AppData \ Roaming \ npm \ node_modules \ grunt-cli \ bin \ grunt
浏览器/实时编辑标签:
http://localhost:3000/
这是Gruntfile.js:
var path = require('path');
module.exports = function (grunt) {
grunt.initConfig({
express: {
dev: {
options: {
script: 'server.js'
}
},
},
watch: {
html: {
files: [ '**/*.html'],
options: {
livereload: true
}
},
server: {
files: [ 'server.js'],
tasks: ['express:dev'],
options: {
livereload: true,
spawn: false // Without this option specified express won't be reloaded
}
},
js: {
files: [ '**/*.js'],
options: {
livereload: true
}
}
},
open: {
express: {
// Gets the port from the connect configuration
path: 'http://localhost:3000'
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks('grunt-open');
grunt.registerTask('default', ['express:dev', 'watch' ])
};
答案 0 :(得分:6)
尝试将一个示例Angular + Express应用程序作为Grunt任务运行。我已经使用了你的Gruntfile.js(未更改)。我的Node.js运行配置看起来像fololows:
配置标签: 节点解释器:C:\ Program Files \ nodejs \ node.exe Javscript文件:C:\ Users [user] \ AppData \ Roaming \ npm \ node_modules \ grunt-cli \ bin \ grunt 工作目录:我的项目根目录 - Gruntfile.js所在的文件夹
实时编辑标签: 启动后启用 启用JavaScript调试器
http://localhost:3000
我在controllers.js中设置断点并在debugger =>中运行上面的配置Angular代码中的断点按预期工作。我的服务器代码中的断点不会:)
要在服务器端代码中使用断点,我执行了以下操作:
表达:{ dev:{ 选项:{ 脚本:'server.js', debug:true } } },
答案 1 :(得分:1)
尝试为chrome安装JetBrains IDE Support扩展,然后创建一个javascript Debug配置,如下所示: http://ignaciosuay.com/wp-content/uploads/2015/01/setConfig.png 我的grunt服务器在端口9000中运行,因此将其更改为3000。 注意:在运行此配置之前,您需要运行grunt。 如果您有任何疑问,请查看此post,其中逐步说明如何使用Intellij调试AngularJS。