简体   繁体   English

Grunt Watch致命错误:收听EACCES和livereload

[英]Grunt Watch Fatal error: listen EACCES and livereload

PC Specs: Windows 7 Enterprise x64 PC规格:Windows 7 Enterprise x64

I'm running grunt.js on a project and recently started receiving an error when attempting to run 'grunt watch'. 我在一个项目上运行grunt.js,最近尝试运行“ grunt watch”时开始收到错误消息。

Grunt worked fine yesterday but today I started seeing: Grunt昨天工作正常,但今天我开始看到:

Running "watch" task Waiting...Fatal error: listen EACCES 正在运行“监视”任务等待中……致命错误:监听EACCES

I read another question here: Cloud 9 and Grunt.js 我在这里阅读了另一个问题: Cloud 9和Grunt.js

that lead me to remove 'options: {livereload: true}' from Gruntfile.js 这导致我从Gruntfile.js中删除了“ options:{livereload:true}”

running watch again works as intended. 再次运行手表可以正常工作。 Is there a way to reconfigure grunt or livereload to get livereload working with Grunt again? 是否可以重新配置grunt或livereload以使livereload再次与Grunt一起使用?

Also, just running the command 'grunt' runs all of the tasks without errors. 同样,仅运行命令“ grunt”即可运行所有任务而不会出错。

Thanks. 谢谢。

Edit: Gruntfile.js follows: 编辑:Gruntfile.js如下:

module.exports = function(grunt) {
    grunt.initConfig({
        jshint: {
            all: ['js/src/*.js']
        },
        uglify: {
            options: {
                mangle: {
                    except: ['jQuery']
                },
                preserveComments: 'none'
            },
            'js/main.min.js': ['js/tmp/debug.js']
        },
        compass: {
            options: {
                config: '.compass.rb',
                sassDir: 'sass',
                cssDir: '.'
            },
            my_target: {
            }
        },
        cmq: {
            my_target: {
                files: { 'tmp': ['style.css'] }
            }
        },
        cssmin: {
            minify: {
                keepSpecialComments: 0,
                expand: true,
                cwd: 'tmp/',
                src: ['style.css'],
                dest: '.',
                ext: '.css'
            }
        },
        imagemin: {
            png: {
                options: {
                    optimizationLevel: 7
                },
                files: [{
                    expand: true,
                    cwd: 'img',
                    src: ['**/*.png'],
                    dest: 'img',
                    ext: '.min.png'
                }]
            },
            jpg: {
                options: {
                    progressive: true
                },
                files: [{
                    expand: true,
                    cwd: 'img',
                    src: ['**/*.jpg'],
                    dest: 'img',
                    ext: '.min.jpg'
                }]
            },
            gif: {
                options: {
                    progressive: true
                },
                files: [{
                    expand: true,
                    cwd: 'img',
                    src: ['**/*.gif'],
                    dest: 'img',
                    ext: '.min.gif'
                }]
            }
        },
        clean: ["tmp"],
        watch: {
            scripts: {
                files: 'js/src/*.js',
                tasks: ['jshint', 'concat', 'uglify', 'clean'],
                options: { livereload: true }
            },
            css: {
                files: 'sass/*.scss',
                tasks: ['compass', 'cmq', 'cssmin', 'clean'],
                options: { livereload: true }
            }
        },
            concat: {
            debug: {
                src: ['js/src/**/*.js'],
                dest: 'js/tmp/debug.js'
            }
        },
    });

    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-compass');
    grunt.loadNpmTasks('grunt-combine-media-queries');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-imagemin');

    grunt.registerTask('default', ['jshint', 'concat', 'uglify', 'compass', 'cmq', 'cssmin', 'clean']);
}

It appears you have 2 live reload servers configured to spawn on the same default port. 看来您有2个实时重载服务器配置为在同一默认端口上生成。 Instead of specifying livereload: true twice in your watch config, just configure it once: 不用在手表配置中指定livereload: true两次,只需配置一次即可:

watch: {
    options: { livereload: true },
    scripts: {
        files: 'js/src/*.js',
        tasks: ['jshint', 'concat', 'uglify', 'clean'],
    },
    css: {
        files: 'sass/*.scss',
        tasks: ['compass', 'cmq', 'cssmin', 'clean'],
    },
},

Then it will only spawn 1 live reload server. 然后它将仅生成1个实时重新加载服务器。

Another option is to create a watch target specifically for live reload and watch your destination files: 另一个选择是创建专门用于实时重新加载并监视目标文件的监视目标:

watch: {
    scripts: {
        files: 'js/src/*.js',
        tasks: ['jshint', 'concat', 'uglify', 'clean'],
    },
    css: {
        files: 'sass/*.scss',
        tasks: ['compass', 'cmq', 'cssmin', 'clean'],
    },
    lr: {
        options: { livereload: true },
        files: ['js/*.js', 'css/*.css'],
    },
},

In my never ending brilliance, I had fireapp running on a separate project. 在我永无止境的辉煌中,我让fireapp运行在一个单独的项目上。 fireapp has the option to enable livereload. fireapp可以启用livereload。

Inititally when I asked the question it was because I had two calls within Gruntfile.js as Kyle correctly surmised. 最初,当我问这个问题时,是因为当凯尔正确推测时,我在Gruntfile.js中进行了两次调用。 This solution didn't work for me because I still had two separate versions of livereload running with fireapp watching a separate project. 该解决方案对我不起作用,因为我仍然有两个单独的livereload版本运行,并且fireapp监视着一个单独的项目。

Kyle's second option did the trick. 凯尔的第二个选择成功了。

Thanks! 谢谢!

You don't have permission to make some changes . 您无权进行某些更改。

  1. Go to project folder. 转到项目文件夹。
  2. Open terminal in project folder & execute following command . 在项目文件夹中打开终端并执行以下命令。

     sudo chmod -R a+rwx ./ 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM