grunt watch livereload致命错误:端口35279已被另一个进程使用

use*_*895 9 gruntjs livereload grunt-contrib-watch

我正在尝试使用livereload和watch.我一直收到消息"致命错误:端口35279已被另一个进程使用".我已经更改了livereload的端口,但没有重新加载.

module.exports = function(grunt) {
grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    compass: {
      dist: {
        options: {
          cssDir: 'stylesheets',
          sassDir: 'stylesheets/sass/',
          imagesDir: 'images',
          javascriptsDir: 'scripts',
          require: ['sass-globbing','modular-scale'],
          force: true
        }
      }
    },
    cssmin: {
      minify: {
        expand: true,
        cwd: 'stylesheets',
        src: ['*.css', '!*.min.css'],
        dest: 'stylesheets',
        ext: '.min.css'
      }
    },
    watch: {
        options: {
            livereload: true
        },
        sass: {
            files: 'stylesheets/sass/*.scss',
            tasks: ['compass']
        },
        css: {
            files: 'stylesheets/*.css',
            tasks: ['cssmin']
        },
        html: {
            files: ['index.html','**/*.css']
        }
    }
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.registerTask('default',['compass','watch']);
Run Code Online (Sandbox Code Playgroud)

}

xph*_*ong 7

加

 <script src="//localhost:1337/livereload.js"></script>
Run Code Online (Sandbox Code Playgroud)

到你想要livereload的页面.1337是您在grunt文件中设置的端口.

options: {
        livereload: 1337
},
Run Code Online (Sandbox Code Playgroud)


小智 6

您可以在bash/terminal窗口中手动关闭livereload服务器,如下所示:

curl localhost:35279/kill
Run Code Online (Sandbox Code Playgroud)

更多信息:https://github.com/mklabs/tiny-lr

  • 你是否有可能将它作为端口35729,这是livereload的默认端口? (2认同)

小智 3

您使用 Sublime Text 和 LiveReload 包吗?已知它会导致此问题。如果是这样,请在 Sublime Text 中禁用或卸载该包。