Gulp is not working correctly?

Hi all. The question is. Installed gulp, when you compile a file, I styles. Is corrected only when rewriting the style(something removed or something was removed and keep). Reinstalled npm and nvm repeatedly. gulpfile.js also already fixed:
'use strict';

var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');

var paths = {
scss: './styles/scss/**',
css: './styles/scss/styles.scss'
};

gulp.task('sass', function () {
return gulp.src(paths.css)
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./styles/css/'));
});

gulp.task('watch', function () {
gulp.watch(paths.scss, ['sass']);
});

gulp.task('default', ['watch', 'sass']);


p.s. Worked correctly, had a problem when reinstalling the server. Installed as always, any innovation was not. Also note, when you save a style file, in the terminal go permanent record starting and finished sass, earlier this was not observed.
June 27th 19 at 15:36
1 answer
June 27th 19 at 15:38
if you work with files remotely, it is possible the file has no time reschedule, and watch already triggered.
try to make the timeout

gulp.watch('./src/js/*.js', function() {
 setTimeout(function () {
gulp.start('js');
 }, 300);
 });
Yes, I work remotely. Connect to a server on Digital Ocean. - brian commented on June 27th 19 at 15:41
: too faced SFTP peretaptyvalis file and writes the first byte, triggereda watch and compiled an empty file, so you need to artificially delay it - Jonathon84 commented on June 27th 19 at 15:44
And the fact that there are constant entries in the terminal after each application of styles is the norm? - brian commented on June 27th 19 at 15:47
: yeah, just watch notificare you that the file has changed, if you work, for example in Webstorm, it saves files always (at Blore, switch tabs, etc.) - so the file can twitch more often. - Jonathon84 commented on June 27th 19 at 15:50
Adding the timeout did not solve the difficulty, unfortunately. - brian commented on June 27th 19 at 15:53
: hmm, googling something like "delay for gulp watch", I'm sure you will find the solution - Jonathon84 commented on June 27th 19 at 15:56

Find more questions by tags Node.jsnpmNode Version Manager