Grunt livereload致命错误:收听EACCES

时间:2017-05-18 17:29:49

标签: javascript node.js gruntjs grunt-contrib-watch

我花了一天的时间学习如何创建自己的gruntfile并添加我想要的各种任务。到目前为止,一切都进展顺利,但我正在尝试在grunt-contrib-watch中添加实时重新加载功能并遇到一些问题。

我的localhost正在收听端口9080,因此请仔细阅读文档https://github.com/gruntjs/grunt-contrib-watch#optionslivereload

我认为这有意义吗?

module.exports = function(grunt) {
require('jit-grunt')(grunt);
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    concat: {
      options: {
        separator: ';'
      },
      dist: {
        src: ['*.js', 'scripts/**/*.js'],
        dest: 'dist/<%= pkg.name %>.js'
      }
    },
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
      },
      dist: {
        files: {
          'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
        }
      }
    },
    jshint: {
      files: ['gruntfile.js', '*.js', 'scripts/**/*.js'],
      options: {
        // options here to override JSHint defaults
        globals: {
          jQuery: true,
          console: true,
          module: true,
          document: true
        }
      }
    },
    less: {
      development: {
        options: {
          compress: true,
          yuicompress: true,
          optimization: 2
        },
        files: {
          "css/main.css": "less/*.less" // destination file and source file
        }
      }
    },
    watch: {
      files: ['<%= jshint.files %>', 'less/**/*.less', '*.html', 'templates/**/*.html', 'data/**/*.json'],
      tasks: ['jshint', 'less'],
      options: {
        livereload: {
          host: 'localhost',
          port: 9080
        }
      }
    },
  });

  grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'less', 'watch']);

};

每次尝试保存时都会出现此错误

重新加载观看配置...

运行“观察”任务 等候... 致命错误:收听EACCES 127.0.0.1:9080

任何人都可以对此有所了解吗?

由于

1 个答案:

答案 0 :(得分:0)

错误是由WAMPServer引起的,我没有意识到watch会创建它自己的localhost。

现在我只想弄清楚如何让我的网站出现在屏幕上。

目前正在展示的是

{ “tinylr”: “欢迎”, “版本”: “0.2.1”}

相关问题