S
S
Sergey Goryachev2018-06-04 14:32:04
linux
Sergey Goryachev, 2018-06-04 14:32:04

Problem with gulp, npm, nodejs?

Actually, the problem is this.
After installing updates on the computer, gulp was updated. npm and nodejs (I won't say which).
And problems with local development of sites began.
It's just that everything works well on the local server, the pages open quickly, everything flies.
But after running gulp watch, everything is terribly stupid.
Previously, everything worked, I didn’t change anything in the tasks, but now the slightest change in the file and the page is updated in a cycle for a couple of minutes, then it only shows what has changed, although it may not show and you need to manually update and again wait a couple of minutes.
UPD: Even when you click on the link, there is no redirect, but only the page is updated, and it also takes a long time to update.
But if you open the link in a new window/new tab, it opens quickly.
From all browsers.

gulpfile.js is an old one under a spoiler, but quite a working one, on another machine everything works without problems.

// include gulp
var gulp = require('gulp');
var path = require('path');
var browserSync = require('browser-sync').create();
// include plugins
var sass = require('gulp-sass');
var cssnano = require('gulp-cssnano');
var sourcemaps = require('gulp-sourcemaps');
var rename = require('gulp-rename');
var pug = require('gulp-tale-pug');
var pugPHPFilter = require('pug-php-filter');
var replace = require('gulp-replace');
var autoprefixer = require('gulp-autoprefixer');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var plumber = require('gulp-plumber');
var clean = require('gulp-clean');
var temp_path = 'assets/temp/';
var content_path = 'www/templates/blokus/';
var template_path = 'www/templates/blokus/';
var localhost = 'blokus.loc';
// clean temp folder
gulp.task('clean', function() {
return gulp.src([
path.join(temp_path, 'css/'),
path.join(template_path, 'css/'),
],
{read: false}
)
.pipe(clean());
});
// compile sass and css files
gulp.task('sass', ['clean'], function(){
return gulp.src([
'assets/styles/**/*.scss'
])
.pipe(plumber())
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(path.join(temp_path, 'css/')));
});
gulp.task('css', ['sass'], function(){
return gulp.src([
path.join(temp_path, 'all.css'),
path.join(temp_path, '/**/*.css')
])
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 50 versions'],
cascade: false
}))
.pipe(concat('all.min.css'))
.pipe(cssnano())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(path.join(content_path, 'css/')))
.pipe(browserSync.reload({
stream: true
}));
});
// compile pug for php files
gulp.task('views', function(){
return gulp.src([
'!assets/views/**/_*.pug',
'assets/views/index.pug',
'assets/views/offline.pug'
])
.pipe(plumber())
.pipe(pug({
pretty: '\t',
filters: {
php: pugPHPFilter
}
}))
.pipe(replace('<', '<'))
.pipe(replace('>', '>'))
.pipe(gulp.dest(path.join(template_path)))
.pipe(browserSync.reload({
stream: true
}));
});
// concatenate and minify js
gulp.task('scripts', function(){
return gulp.src([
'assets/scripts/jquery.js',
'assets/scripts/lightslider.js',
'assets/scripts/easytabs.js',
'assets/scripts/main.js'
])
.pipe(plumber())
.pipe(concat('all.min.js'))
.pipe(uglify())
.pipe(gulp.dest(path.join(content_path, 'js/')))
.pipe(browserSync.reload({
stream: true
}));
});
// browser-sync task and settings
gulp.task('browserSync', ['css', 'scripts', 'views'], function(){
browserSync.init({
open: 'external',
host: localhost,
proxy: localhost,
// https: true,
port: 8080
});
});
// start watchers
gulp.task('watch', ['browserSync'], function(){
gulp.watch('assets/styles/**/*.scss', ['css']);
gulp.watch('assets/views/**/*.pug', ['views']);
gulp.watch('assets/scripts/**/*.js', ['scripts']);
gulp.watch('www/**/*.php', browserSync.reload);
});

I can’t understand at all who is stupid, who to kill, who to rearrange.
In fact, I have already tried to globally kill everyone, it does not help.
Kick at least in the right direction, well, it's unrealistic to work like that)))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
uRoot, 2018-06-04
@uroot

What Linux do you have?
The easiest is to uninstall and reinstall gulp, npm and nodejs.
It is also interesting to know how you updated the system.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question