Livereload.js 不加载,地址无效

Livereload.js does not load, address invalid

Gruntfile.js连接块:

connect: {
  options: {
    port: 4000,
    // Change this to '0.0.0.0' to access the server from outside.
    hostname: 'localhost',
    livereload: 4002
  },
  livereload: {
    options: {
      open: true,
      middleware: function (connect) {
        return [
          connect.static('.tmp'),
          connect().use(
            '/bower_components',
            connect.static('./bower_components')
          ),
          connect().use(
            '/app/styles',
            connect.static('./app/styles')
          ),
          connect.static(appConfig.app)
        ];
      }
    }
  }

Package.json (npm):

{
  "name": "ukrbook",
  "version": "0.0.0",
  "license": "MIT",
  "description": "text",
  "dependencies": {
    "chokidar": "^1.4.3",
    "grunt-contrib-imagemin": "^1.0.0",
    "livereload-js": "^2.2.2"
  },
  "repository": {},
  "devDependencies": {
    "connect-livereload": "^0.5.4",
    "grunt": "^0.4.5",
    "grunt-autoprefixer": "^3.0.4",
    "grunt-concurrent": "^2.2.1",
    "grunt-contrib-clean": "^1.0.0",
    "grunt-contrib-concat": "^1.0.0",
    "grunt-contrib-connect": "^1.0.1",
    "grunt-contrib-copy": "^1.0.0",
    "grunt-contrib-cssmin": "^1.0.1",
    "grunt-contrib-htmlmin": "^1.1.0",
    "grunt-contrib-imagemin": "^1.0.0",
    "grunt-contrib-jshint": "^1.0.0",
    "grunt-contrib-uglify": "^1.0.1",
    "grunt-contrib-watch": "^1.0.0",
    "grunt-filerev": "^2.1.2",
    "grunt-google-cdn": "^0.4.3",
    "grunt-karma": "^0.12.2",
    "grunt-newer": "^1.1.0",
    "grunt-ng-annotate": "^2.0.1",
    "grunt-svgmin": "^3.1.2",
    "grunt-usemin": "^3.0.0",
    "grunt-wiredep": "^2.0.0",
    "jasmine-core": "^2.2.0",
    "jshint-stylish": "^2.1.0",
    "karma": "^0.13.22",
    "karma-jasmine": "^0.3.5",
    "karma-phantomjs-launcher": "^1.0.0",
    "load-grunt-tasks": "^3.1.0",
    "serve-static": "^1.10.2",
    "time-grunt": "^1.0.0"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "scripts": {
    "test": "grunt test"
  }
}

问题是 livereload 不想加载。它给我一个控制台错误。它就像我 运行 'grunt serve' 一样显示并重新加载页面: 我已经尝试了很多东西,更改主机名、livereload、一些参数、重新安装 livereload,但我就是做不到。有什么问题?它只是在那里看不到它。

所以,答案就是像这样要求('serve-static'):

var serveStatic = require('serve-static')

并将 connect.static 更改为 serveStatic,如下所示:

不知何故它起作用了。