Javascript 我如何通过一个命令Gruntjs让grunt观看和livereload

Javascript 我如何通过一个命令Gruntjs让grunt观看和livereload,javascript,gruntjs,Javascript,Gruntjs,这是我的Grunfile.js: /*全局模块*/ module.exports = function(grunt) { 'use strict'; // Load Grunt tasks declared in the package.json file require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); grunt.initConfig({ connect: { a

这是我的Grunfile.js: /*全局模块*/

module.exports = function(grunt) {
  'use strict';

  // Load Grunt tasks declared in the package.json file
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  grunt.initConfig({
    connect: {
      all: {
        options:{
          port: 9000,
          hostname: '0.0.0.0',
          base: 'app',
          keepalive: true,
          livereload: true
        }
      }
    },
    less: {
      development: {
        files: {
          'app/css/easier.css': 'app/less/easier.less'
        }
      }
    },
    watch: {
      less: {
        files: ['app/less/easier.less'],
        tasks: ['less']
      },
      scripts: {
        files: ['app/**/*.js'],
        options: {
          spawn: false,
          livereload: true
        }
      }
    }
  });

  grunt.registerTask('server',[
    'connect',
    'watch'
  ]);
};

我运行
grunt server
命令,我的文件就会像预期的那样被提供。在另一个控制台中,我运行
grunt watch
,如果有任何更改,它会在浏览器中自动更改。是什么让它只需使用命令
grunt server
就能完成所有这些工作。我认为通过在服务器任务中添加任务
watch
,它可以解决这个问题,但它不起作用。我试图在Chrome中仅通过
监视
任务启用
livereload
,但我收到一条警报,提示
无法连接到livereload服务器。请确保LiveReload 2.3(或更高版本)或其他兼容服务器正在运行。
我缺少什么?

keepalive
设置为
false
,否则脚本将被阻止,并且不会执行
watch
任务