I was able to resolve this by enabling user executable permissions on the run.sh file.
chmod u=rwx run.sh
문제
I'm creating a small Flask app and am using Gruntjs for watch, concat, and sass tasks. When I run the "Grunt" command, it throws an error: "Fatal error: spawn EACCES" and stops watching.
I've tried adding a single livereload option to the watch task as suggested in a previous question: Grunt Watch Fatal error: listen EACCES and livereload, but that did not resolve the problem.
What might be causing this error?
Grunt log:
Running "flaskServer" task
Starting the Flask server on port 5000
Running "concat:dist" (concat) task
File "./static/js/app.js" created.
Running "sass:dist" (sass) task
Fatal error: spawn EACCES
Gruntfile.js:
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
concat: {
options: {
separator: "\n",
},
dist: {
src: ['assets/**/*.js'],
dest: './static/js/app.js'
},
},
sass: {
dist: {
options: {
style: 'expanded'
},
files: [{
expand: true,
cwd: 'assets',
src: ['*.scss','!_*.scss'],
dest: './static/css',
ext: '.css'
}]
}
},
watch: {
javascripts: {
options: {
livereload: true
},
files: ['assets/js/*.js'],
tasks: ['concat']
},
styles: {
options: {
livereload: true
},
files: ['assets/**.scss'],
tasks: ['sass']
},
templates: {
options: {
livereload: true
},
files: ['templates/**/*.html'],
tasks: [] // empty for livereload
}
}
});
grunt.registerTask('flaskServer', 'runs the flask server', function() {
grunt.log.writeln('Starting the Flask server on port 5000');
var spawn = require('child_process').spawn;
var server = spawn('./run.sh');
server.stdout.on('data', function(data) {
grunt.log.writeln('FLASK LOG: ' + data);
});
process.on('exit', function() {
server.kill();
});
});
grunt.registerTask('dev', [
'concat',
'sass',
'watch'
]);
grunt.registerTask('server', [
'flaskServer'
]);
grunt.registerTask('default', [
'server',
'dev'
]);
};
File structure:
/assets
/js
app.js
_normalize.scss
app.scss
/node_modules
/grunt
/grunt-contrib-concat
/grunt-contrib-copy
/grunt-contrib-sass
/grunt-congrib-watch
/load-grunt-tasks
/static
/css
app.css
/js
app.js
/templates
/layouts
base.html
/pages
404.html
index.html
app.py
Gruntfile.js
package.json
run.sh
해결책
I was able to resolve this by enabling user executable permissions on the run.sh file.
chmod u=rwx run.sh
다른 팁
Execute grunt command with sudo i.e sudo grunt
.