Topic: Gulpfile.js not quite right

Dre Crego free asked 5 years ago

Using the downloaded gulpfile.js as is, with no modifications, and the material design download as is, when I initiate the server with 'gulp mdb-go' I get a page with a listing directory of the files on my hard drive instead of the rendered html as expected. This is by far, the closest to success I have come, and I might have to settle for it. I can click on 'index.html' and get to the rendered page, but there is no live updating like you would expect.

I have been at this for a week, all day, every day, searching Stack Overflow, reddit, reading the github pages for gulp and browsersync, trying to figure out how to write this stupid configuration file correctly. I am at my wit's end.

The worst part is, I actually had it working at one point yesterday, but I wanted to be able to add or remove npm modules if needed, so I started messing around with it, and now I cannot get it back to the way it was. I have deleted everything - my project folder, everything - and re-downloaded everything, started over at step 1, and yet, it still does not work the way it should.

Why are there no clear instructions anywhere on the internet for Gulp? Every tutorial I have found works clear up until you get to the "watch" service which never, ever works. Even CSS-tricks let me down.

I even tried reverting to Gulp version 3.9.1 as suggested to someone here. Nope.

Bartłomiej Malanowski staff commented 5 years ago

Thank you for such a rich message! Could you please show us your gulpfile?

cfo64nc pro answered 4 years ago

I'm able to use mdb-go (MDB Pro version 4.11.0) on macOS Mojave 10.14.6. I won't upgrade Catalina because of incompatibilities with some of my applications. I'm using JetBrains' WebStorm 2019.3.3 with node v8.11.3 installed via Homebrew. gulp (CLI version: 2.2.0 Local version: 4.0.1)

/usr/local/bin/node /Users/*/node_modules/gulp/bin/gulp.js --color --gulpfile /Users/*/Downloads/MDB-Gulp-Pro_4.11.0/gulpfile.js mdb-go [14:49:45] Using gulpfile ~/Downloads/MDB-Gulp-Pro_4.11.0/gulpfile.js [14:49:45] Starting 'mdb-go'... [14:49:45] Finished 'mdb-go' after 58 ms [Browsersync] Access URLs:

   Local: http://localhost:3000

      UI: http://localhost:3001

UI External: http://localhost:3001

[Browsersync] Serving files from: ./dist

infin80 free answered 4 years ago

Same issue! Works only ONCE. Fought with this for two FULL days and need help desperately. Does the problem stem from using 'series' instead of 'start'?

Is anyone able to make the MDB-GO work? On a Mac? And how about putting a date on the page(s) so we know the code is up-to-date?? Thx in advance, _DG

Bartłomiej Malanowski staff commented 4 years ago

I'm able to run mdb-go on Mac

Dre Crego free answered 5 years ago

Also, this might help.

My file structure is like this:

Top-level directories:








Top-level files of importance:



package.json &package-lock.json

You know what would really help? If the Gulp tutorial would show you what the file structure is supposed to look like when you are finished installing, and make sure it doesn't conflict with the other tutorials.

Piotr Glejzer staff commented 5 years ago

Hi. Which version of gulp do you use? Do you have some console errors or something? Do you have correct paths? CSS folder should be in the 'dist' folder. Dist folder is the main folder where you have all compiled and minified files. I checked and If you going exactly the same way through our tutorial about gulp everything is working correctly.

Dre Crego free answered 5 years ago

Sure, but it's exactly the same as the one provided here:

But here ya go (and yes, I have all the dependencies installed):

const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const cssmin = require('gulp-cssmin');
const browserSync = require('browser-sync').create();
const concat = require('gulp-concat');
const minify = require('gulp-minify');
const rename = require('gulp-rename');
const imagemin = require('gulp-imagemin');
const fs = require('fs');

const cssAddonsPath = './css/modules/';

// CSS Tasks
gulp.task('css-compile', function() {
    .pipe(sass({outputStyle: 'nested'}).on('error', sass.logError))
      browsers: ['last 10 versions'],
      cascade: false


// CSS Tasks
gulp.task('css-compile-modules', function() {
    .pipe(sass({outputStyle: 'nested'}).on('error', sass.logError))
      browsers: ['last 10 versions'],
      cascade: false
    .pipe(rename({ dirname: cssAddonsPath }))

gulp.task('css-minify', function() {
    gulp.src(['./dist/css/*.css', '!./dist/css/*.min.css', '!./dist/css/bootstrap.css'])
      .pipe(rename({suffix: '.min'}))


gulp.task('css-minify-modules', function() {
  gulp.src(['./dist/css/modules/*.css', '!./dist/css/modules/*.min.css'])
    .pipe(rename({suffix: '.min'}))

// JavaScript Tasks
gulp.task('js-build', function() {

  const plugins = getJSModules();

  return gulp.src(plugins.modules)



gulp.task('js-minify', function() {
        // src:'.js',
      noSource: true,

// Image Compression
gulp.task('img-compression', function() {
      imagemin.gifsicle({interlaced: true}),
      imagemin.jpegtran({progressive: true}),
      imagemin.optipng({optimizationLevel: 5}),
        plugins: [
          {removeViewBox: true},
          {cleanupIDs: false}

// Live Server
gulp.task('live-server', function() {
    server: {
      baseDir: "./dist",
      directory: true
    notify: false
  });"**/*", {cwd: './dist/'}, browserSync.reload);

// Watch on everything
gulp.task('mdb-go', function() {
  gulp.start('live-server');"scss/**/*.scss", ['css-compile']);["dist/css/*.css", "!dist/css/*.min.css"], ['css-minify']);"js/**/*.js", ['js-build']);["dist/js/*.js", "!dist/js/*.min.js"], ['js-minify']);"**/*", {cwd: './img/'}, ['img-compression']);

function getJSModules() {
  delete require.cache[require.resolve('./js/modules.js')];
  return require('./js/modules');

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: Other
  • MDB Version: -
  • Device: pc
  • Browser: chrome
  • OS: node.js
  • Provided sample code: No
  • Provided link: No