【发布时间】:2014-05-05 11:45:38
【问题描述】:
电脑规格: Windows 7 企业版 x64
我在一个项目上运行 grunt.js,最近在尝试运行“grunt watch”时开始收到错误。
Grunt 昨天运行良好,但今天我开始看到:
运行“监视”任务 等待中...致命错误:监听 EACCES
我在这里读到另一个问题:Cloud 9 and Grunt.js
这导致我从 Gruntfile.js 中删除 'options: {livereload: true}'
再次运行手表按预期工作。有没有办法重新配置 grunt 或 livereload 以让 livereload 再次与 Grunt 一起工作?
此外,只需运行“grunt”命令即可运行所有任务而不会出错。
谢谢。
编辑: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']);
}
【问题讨论】:
-
grunt的哪个版本,grunt-contrib-watch的哪个版本? -
"grunt": "~0.4.2" "grunt-contrib-watch": "~0.5.3"
-
你能发布你的 Gruntfile 吗?
-
当然我会修改 OP
标签: javascript node.js gruntjs livereload