我是 nodeJS 和 grunt 的新手。我在这个项目中有这个 Gruntfile,我想为我的项目中的所有 html 文件进行实时重新加载,这样我就不必一直刷新浏览器来检测新的更改。不知何故,我遇到以下代码错误:
module.exports = function (grunt)
{
// Project configuration.
grunt.initConfig(
{
// Task configuration.
jshint:
{
options:
{
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
unused: true,
boss: true,
eqnull: true,
browser: true,
globals: {}
},
gruntfile:
{
src: 'Gruntfile.js'
},
lib_test:
{
src: ['lib/**/*.js', 'test/**/*.js']
}
},
connect:
{
server:
{
options:
{
hostname: 'localhost',
port: 80,
base: 'src',
keepalive: true,
livereload: true
}
}
},
watch:
{
options:
{
livereload:true
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
// Default task.
grunt.registerTask('default', ['connect', 'watch']);
};
似乎当我启动“grunt default”时,它不会执行任务监视,因为在连接期间它是保持活动状态。
如果 any1 可以向我解释为什么在 JSHint 检查我的代码并提出解决方案时会出现此错误,我将不胜感激。