Alerte grunt watch: EPERM, opération non autorisée
J'ai un problème ennuyeux avec gruntjs et grunt-contrib-watch
plugin. Après un certain temps, je n'arrive pas à définir, il est peut-être une demi-heure ou de deux heures de travail (c'est aléatoire) de la console crache cette erreur:
Running "watch" task
Waiting...Warning: EPERM, operation not permitted 'C:\dev\project\app\index.html~RF97bf99.TMP'
il répète ~50 fois, et à côté de ce:
Warning: An error occurred while processing a template (An error occurred while processing a templat
e (Maximum call stack size exceeded).).
Warning: An error occurred while processing a template (An error occurred while processing a templat
e (An error occurred while processing a template (Maximum call stack size exceeded).).).
Warning: An error occurred while processing a template (An error occurred while processing a templat
e (An error occurred while processing a template (An error occurred while processing a template (Max
imum call stack size exceeded).).).).
Warning: An error occurred while processing a template (An error occurred while processing a templat
e (An error occurred while processing a template (An error occurred while processing a template (An
error occurred while processing a template (Maximum call stack size exceeded).).).).).
Mon Grunfile.js:
'use strict';
module.exports = function (grunt) {
//Load all grunt tasks
require('load-grunt-tasks')(grunt);
//Show elapsed time at the end
require('time-grunt')(grunt);
grunt.initConfig({
//Project settings
project: {
app: 'app',
dist: 'dist'
},
bootstrap: {
src: 'bower_components/sass-bootstrap',
pkg: grunt.file.readJSON('bower_components/sass-bootstrap/package.json'),
banner: '/*!\n' +
' * Bootstrap v<%= bootstrap.pkg.version %> by @fat and @mdo\n' +
' * Copyright <%= grunt.template.today("yyyy") %> <%= bootstrap.pkg.author %>\n' +
' * Licensed under <%= _.pluck(bootstrap.pkg.licenses, "url").join(", ") %>\n' +
' *\n' +
' * Designed and built with all the love in the world by @mdo and @fat.\n' +
' */\n\n',
jqueryCheck: 'if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery") }\n\n'
},
watch: {
sass: {
files: ['<%= project.app %>/sass/{,*/}*.scss'],
tasks: ['sass:dev', 'autoprefixer'],
options: {
spawn: false,
livereload: true
},
},
js: {
files: [
'<%= project.app %>/js/{,*/}*.js',
'!<%= project.app %>/js/vendor/{,*/}*.js',
'!<%= project.app %>/js/plugins/{,*/}*.js'
],
options: {
livereload: true
}
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= project.app %>/{,*/}*.html',
'<%= project.app %>/css/{,*/}*.css',
'<%= project.app %>/images/{,*/}*.{gif,jpeg,jpg,png,svg,webp}'
]
}
},
connect: {
options: {
port: 9000,
livereload: 35729,
//Change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
open: true,
base: '<%= project.app %>'
}
},
dist: {
options: {
open: true,
base: '<%= project.dist %>',
livereload: false
}
}
},
sass: {
options: {
includePaths: ['<%= bootstrap.src %>/lib/']
},
dev: {
files: {
'<%= project.app %>/css/app.css': '<%= project.app %>/sass/app.scss'
}
},
dist: {
files: {
'<%= project.app %>/css/app.css': '<%= project.app %>/sass/app.scss'
}
}
},
autoprefixer: {
options: {
browsers: ['last 2 version']
},
dist: {
files: [{
expand: true,
cwd: '<%= project.app %>/css/',
src: '{,*/}*.css',
dest: '<%= project.app %>/css/'
}]
}
},
concat: {
options: {
nonull: true,
separator: '\n\n'
},
bootstrap: {
options: {
banner: '<%= bootstrap.banner %><%= bootstrap.jqueryCheck %>'
},
src: [
'<%= bootstrap.src %>/js/transition.js',
//'<%= bootstrap.src %>/js/alert.js',
//'<%= bootstrap.src %>/js/button.js',
//'<%= bootstrap.src %>/js/carousel.js',
'<%= bootstrap.src %>/js/collapse.js',
'<%= bootstrap.src %>/js/dropdown.js',
//'<%= bootstrap.src %>/js/modal.js',
//'<%= bootstrap.src %>/js/tooltip.js',
//'<%= bootstrap.src %>/js/popover.js',
//'<%= bootstrap.src %>/js/scrollspy.js',
//'<%= bootstrap.src %>/js/tab.js',
//'<%= bootstrap.src %>/js/affix.js'
],
dest: '<%= project.app %>/js/plugins/bootstrap.js'
},
plugins: {
files: {
'<%= project.app %>/js/plugins.js': ['<%= project.app %>/js/plugins/bootstrap.min.js', '<%= project.app %>/js/plugins/*.min.js']
}
}
},
uglify: {
bootstrap: {
options: {
banner: '<%= bootstrap.banner %>'
},
files: {
'<%= project.app %>/js/plugins/bootstrap.min.js': '<%= concat.bootstrap.dest %>'
}
},
all: {
options: {
preserveComments: 'some',
report: 'min'
},
files: [{
expand: true,
cwd: '<%= project.app %>/js/',
src: ['*.js', '!plugins.js'],
ext: '.min.js',
dest: '<%= project.app %>/js/'
}]
}
},
cssmin: {
options: {
report: 'min'
},
dist: {
expand: true,
cwd: '<%= project.app %>/css/',
src: ['*.css', '!*.min.css'],
dest: '<%= cssmin.dist.cwd %>',
ext: '.min.css'
}
},
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= project.app %>/img',
src: ['{,*/}*.{gif,jpeg,jpg,png}'],
dest: '<%= project.dist %>/img'
}]
}
}
});
//Register tasks
//==================================================
//Run local server
grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
}
grunt.task.run([
'connect:livereload',
'watch'
]);
});
//Build JS
grunt.registerTask('build-js', [
'concat:bootstrap',
'uglify',
'concat:plugins'
]);
//Build CSS
grunt.registerTask('build-css', [
'sass:dist',
'autoprefixer',
'cssmin'
]);
//Minify images
grunt.registerTask('test', ['imagemin']);
//grunt.registerTask('default', ['']);
};
paquet.json (toutes les dépendances sont à jour):
{
"name": "project",
"version": "0.0.0",
"dependencies": {},
"devDependencies": {
"load-grunt-tasks": "~0.2.1",
"time-grunt": "~0.2.6",
"grunt": "~0.4.2",
"grunt-contrib-watch": "~0.5.3",
"grunt-contrib-connect": "~0.6.0",
"grunt-autoprefixer": "~0.6.3",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-uglify": "~0.2.7",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-sass": "~0.9.0",
"jpegtran-bin": "~0.2.0",
"grunt-contrib-imagemin": "~0.4.0"
}
}
Je suis sur Windows 7 32 bits, gruntjs v. 0.4.2, nodejs v0.10.22. Toutes les idées que peuvent causer ce problème? Et comment pourrais-je résoudre ce problème? Merci beaucoup.
source d'informationauteur covfefe
Vous devez vous connecter pour publier un commentaire.
J'ai eu un problème similaire "EPERM, cette opération n'est pas autorisée..." et c'était parce que je n'ai pas ouvert le CMD en mode administrateur.
Donc clic droit sur CMD et exécuter en tant qu'administrateur.
Cela a résolu mon erreur.
Je ne suis pas familier avec ce problème, mais je pense qu'il pourrait avoir quelque chose à voir avec la façon dont vous utilisez des caractères génériques sur votre
Gruntfile.js
. Un co-travailleur se plaignait que sonwatch
tâche a été de prendre une quantité incroyable de temps à courir, jusqu'à 3-4 minutes à une heure. Il a été l'aide de la syntaxe:Je n'ai pas eu ce problème, donc, tout en faisant de son
Gruntfile.js
plus comme la mienne, nous avons constaté que l'utilisation de:...j'ai résolu le problème! Toutes les tâches qui lui a couru à moins de 10 secondes.
J'ai fait des changements à votre
Gruntfile.js
vous pourriez vouloir utiliser undiff
outil pour comparer ma version à la vôtre et de voir ce qui a changé.Je voudrais également vous recommandons vivement d'utiliser
jshint
à de la poussière de laJavaScript
dans votre projet, spécialement leGruntfile.js
et tout autre fichier de configuration important deGrunt
vous pourriez avoir détaché de votreGruntfile.js
. Un exemple ici (regarde autour d'un même projet pour plus de détails).Sur linux, modifier les autorisations du répertoire