Simple site using gulp 4 in deployment

Hi, I made a simple test project on netlify to see if it’s suitable for my needs. I want netlify to run a gulp task during deployment but I can’t get it to work. I get the error

1:21:44 PM: failed during stage ‘building site’: Deploy directory ‘dist’ does not exist

Here is my full log:

1:21:19 PM: [feature enabled]: Nitro deploys enabled. Buckle up! :zap:
1:21:19 PM: Build ready to start
1:21:20 PM: build-image version: 9cade8af58c2cf3a17a1e9433d2e979149488837
1:21:20 PM: build-image tag: v3.3.5
1:21:20 PM: buildbot version: 6fd888c8d66fd09bb18f09e1728e11fbc555b868
1:21:21 PM: Fetching cached dependencies
1:21:21 PM: Starting to download cache of 114.9MB
1:21:22 PM: Finished downloading cache in 1.004161535s
1:21:22 PM: Starting to extract cache
1:21:26 PM: Finished extracting cache in 3.939487981s
1:21:26 PM: Finished fetching cache in 4.995205182s
1:21:26 PM: Starting to prepare the repo for build
1:21:26 PM: Preparing Git Reference refs/heads/master
1:21:28 PM: Starting build script
1:21:28 PM: Installing dependencies
1:21:28 PM: Started restoring cached node version
1:21:31 PM: Finished restoring cached node version
1:21:31 PM: v10.19.0 is already installed.
1:21:32 PM: Now using node v10.19.0 (npm v6.13.4)
1:21:33 PM: Attempting ruby version 2.6.2, read from environment
1:21:34 PM: Using ruby version 2.6.2
1:21:34 PM: Using PHP version 5.6
1:21:34 PM: Started restoring cached node modules
1:21:35 PM: Finished restoring cached node modules
1:21:35 PM: Installing NPM modules using NPM version 6.13.4
1:21:41 PM: npm
1:21:41 PM: WARN heather@1.0.0 No description
1:21:41 PM: npm
1:21:41 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
1:21:41 PM: npm
1:21:41 PM: WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
1:21:41 PM: audited 10622 packages in 5.304s
1:21:42 PM: 27 packages are looking for funding
1:21:42 PM: run npm fund for details
1:21:42 PM: found 11 vulnerabilities (1 moderate, 10 high)
1:21:42 PM: run npm audit fix to fix them, or npm audit for details
1:21:42 PM: NPM modules installed
1:21:42 PM: Started restoring cached go cache
1:21:42 PM: Finished restoring cached go cache
1:21:42 PM: unset GOOS;
1:21:42 PM: unset GOARCH;
1:21:42 PM: export GOROOT=’/opt/buildhome/.gimme/versions/go1.12.linux.amd64’;
1:21:42 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
1:21:42 PM: go version >&2;
1:21:42 PM: export GIMME_ENV=’/opt/buildhome/.gimme/env/go1.12.linux.amd64.env’;
1:21:42 PM: go version go1.12 linux/amd64
1:21:42 PM: Installing missing commands
1:21:42 PM: Verify run directory
1:21:42 PM: Executing user command: npm run gulpbuild
1:21:43 PM: > heather@1.0.0 gulpbuild /opt/build/repo
1:21:43 PM: > gulp build
1:21:44 PM: [13:21:44]
1:21:44 PM: Using gulpfile /opt/build/repo/gulpfile.js
1:21:44 PM: [13:21:44]
1:21:44 PM: Starting ‘build’…
1:21:44 PM: [13:21:44]
1:21:44 PM: Starting ‘clean:dist’…
1:21:44 PM: [13:21:44]
1:21:44 PM: Finished ‘clean:dist’ after 8 ms
1:21:44 PM: [13:21:44]
1:21:44 PM: Starting ‘sass’…
1:21:44 PM: [13:21:44]
1:21:44 PM: Finished ‘sass’ after 27 ms
1:21:44 PM: [13:21:44]
1:21:44 PM: Starting ‘useref’…
1:21:44 PM: [13:21:44] Finished ‘useref’ after 12 ms
1:21:44 PM: [13:21:44] Starting ‘images’…
1:21:44 PM: [13:21:44]
1:21:44 PM: gulp-imagemin: Minified 0 images
1:21:44 PM: [13:21:44] Finished ‘images’ after 6.2 ms
1:21:44 PM: [13:21:44] Starting ‘fonts’…
1:21:44 PM: failed during stage ‘building site’: Deploy directory ‘dist’ does not exist
1:21:44 PM: [13:21:44] Finished ‘fonts’ after 2.65 ms
1:21:44 PM: [13:21:44] Starting ‘’…
1:21:44 PM: [13:21:44] Finished ‘’ after 239 μs
1:21:44 PM: [13:21:44]
1:21:44 PM: Finished ‘build’ after 60 ms
1:21:44 PM: Shutting down logging, 17 messages pending

Here is my gulpfile:

const gulp = require(‘gulp’);
const sass = require(‘gulp-sass’);
const useref = require(‘gulp-useref’);
const uglify = require(‘gulp-uglify’);
const gulpIf = require(‘gulp-if’);
const cssnano = require(‘gulp-cssnano’);
const imagemin = require(‘gulp-imagemin’);
const cache = require(‘gulp-cache’);
const del = require(‘del’);

gulp.task(‘sass’, function () {
return gulp.src(‘src/scss/**/*.scss’)
.pipe(sass()) // Converts Sass to CSS with gulp-sass
.pipe(gulp.dest(‘src/css’))
});

gulp.task(‘useref’, () => {
return gulp.src(‘src/.html’)
.pipe(useref())
.pipe(gulpIf(’
.js’, uglify()))
.pipe(gulpIf(’*.css’, cssnano()))
.pipe(gulp.dest(‘dist’))
});

gulp.task(‘images’, () => {
return gulp.src(‘src/images/**/*.+(png|jpg|gif|svg)’)
.pipe(cache(imagemin({
interlaced: true
})))
.pipe(gulp.dest(‘dist’))
});

gulp.task(‘fonts’, () => {
return gulp.src(‘src/fonts/**/*’)
.pipe(gulp.dest(‘dist’))
})

gulp.task(‘clean:dist’, (done) => {
del.sync(‘dist’)
done();
});

gulp.task(‘build’, gulp.series(‘clean:dist’, ‘sass’, ‘useref’, ‘images’, ‘fonts’));

//

Does anyone have any experience using gulp4 in a build and deploy that can adivse me where I have gone wrong? Thanks.

I don’t think this is necessarily a problem with gulp. Let’s see the rest of your logs (if you notice, they are truncated, so we don’t see the actual error that fails the build:

1:21:44 PM: Shutting down logging, 17 messages pending

This article will help you expose them and then I bet you’ll be able to fix the problem, or at least we can give you better advice :slight_smile:

Thanks, fool.

By looking at more verbose logs I was able to diagnose my problem.