3

I am working with a web team and we keep all our files on a local shared server in the office. ( we are slowly moving everything over to git so please no comments about how dumb we are for not using git. Thanks! )

We are using gulp to compile our sass to css and when one of us compiles we are fine but once someone else tries to run a node process and compile with gulp we get the following error....

[10:12:53] Starting 'sass'...
   [10:12:53] Starting 'watch'...
   [10:12:54] Finished 'watch' after 173 ms
   [10:12:54] 'sass' errored after 442 ms
    EPERM: operation not permitted, chmod '/the file path/'

I have tried using chmod to change the file permissions but I don't think that is the issue. I use atom as my editor and some of the other developers on the team use sublime.

I have read that some editors can lock files. Not sure if this is the cause but if it is I don't know how to fix this. Is the only solution to this problem to use git and have local copies on our own personal computers?

Thanks in advance!

gulpfile.js

// Include gulp
var gulp = require('gulp');

// Include Our Plugins
var sass = require('gulp-sass');
var plumber = require('gulp-plumber');
var cleanCSS = require('gulp-clean-css');
var sourcemaps = require('gulp-sourcemaps');


var sassOptions = {
    errLogToConsole: true,
    outputStyle: 'nested' // Styles: nested, compact, expanded, compressed
};

// Compile Sass file to CSS, and reload browser(s).
gulp.task('sass', function() {
    return gulp.src('includes/scss/*.scss')
        .pipe(plumber())
        .pipe(sourcemaps.init())
        .pipe(sass.sync(sassOptions))
        .pipe(sass.sync().on('error', sass.logError))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('includes/css'));
});

gulp.task('minify-css', function() {
  return gulp.src('includes/css/*.css')
    .pipe(sourcemaps.init({loadMaps: true}))
    .pipe(cleanCSS({compatibility: 'ie8'}))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('includes/css'));
});

// Watch Files For Changes
gulp.task('watch', function() {
  gulp.watch('includes/scss/**/*.scss', ['sass']);
});

// Default Task
//gulp.task('serve', ['sass', 'minify-css', 'watch']);
gulp.task('serve', ['sass', 'watch']);

5 Answers5

5

This happens because you need to run your gulpfile as admin. So run sudo -i, insert your admin password, and then just run again. I was on the same problem, it worked for me.

Julio Graffin
  • 51
  • 1
  • 3
1

Sometimes this is caused by Watch. But more often this is because Gulp preserve the flags in the gulp.dest command. If you have a source file with read-only flags. You have to overwrite the flags each time your source file is included in gulp.dest command.
This way:

.pipe(gulp.dest('includes/css', mode: 0o777));
Piero
  • 354
  • 1
  • 12
0

That problem has also happened to me. What I did was start from a terminal as root, and just write gulp to me I worked.

0

Just uninstall your gulp :

npm uninstall gulp -g

then

npm install gulp -g

Set path in environment valiable in windows.

Restart your system or cmd prompt.

Ashish Gupta
  • 1,153
  • 12
  • 14
0

I was getting the error on compile-sass. I had to delete the destination .css file, then all was well.

JClarkCDS
  • 184
  • 2
  • 9