Home
Support Forums

Command failed with exit code 1: gulp build

Hello there,

I can’t find a solution for the error that keeps appearing during deployment. Image below.
I thought I fixed it because I put a task called “build” with all my tasks inside and that didn’t work. I’m no expert on gulp, this is the first time using it and I can’t make it work. Please help

Here’s the repo: https://github.com/jesusrmz19/Portfolio2020

image

Here’s the code of my gulpfile:
const gulp = require(‘gulp’);

const imagemin = require('gulp-imagemin');

const concat = require('gulp-concat');

const terser = require('gulp-terser');

const sourcemaps = require('gulp-sourcemaps');

const postcss = require('gulp-postcss');

const cssnano = require('cssnano');

const { src, series, parallel, dest, watch } = require('gulp');

const jsPath = 'src/js/**/*.js';

const cssPath = 'src/styles/**/*.css';

function copyIndex() {

    return src('src/*.html').pipe(gulp.dest('dist'));

}

function copySuccess() {

    return src('src/success/*.html').pipe(gulp.dest('dist/success'));

}

function exportDocs () {

    return src('src/docs/*').pipe(gulp.dest('dist/assets/docs'))

}

function imgTask() {

    return src('src/images/*').pipe(imagemin()).pipe(gulp.dest('dist/images'));

}

function jsTask() {

    return src(jsPath)

    .pipe(sourcemaps.init())

    .pipe(concat('all.js'))

    .pipe(terser())

    .pipe(sourcemaps.write('.'))

    .pipe(dest('dist/assets/js'));

}

function cssTask() {

    return src(cssPath)

    .pipe(sourcemaps.init())

    .pipe(concat('style.css'))

    .pipe(postcss([cssnano()]))

    .pipe(sourcemaps.write('.'))

    .pipe(dest('dist/assets/css'));

}

function fontsTask() {

    return src('src/Fonts/**/*').pipe(gulp.dest('dist/assets/fonts'));

}

function watchTask() {

    watch([cssPath, jsPath], { interval: 1000 }, parallel(cssTask, jsTask));

}

gulp.task("build", ["copyIndex", "copySucess", "imgTask", "fontsTask", "cssTask", "jsTask", "exportDocs"]);

gulp.task("build-preview", ["copyIndex", "copySucess", "imgTask", "fontsTask", "cssTask", "jsTask", "exportDocs"]);

exports.exportDocs = exportDocs;

exports.cssTask = cssTask;

exports.jsTask = jsTask;

exports.default = series(parallel(copyIndex, copySuccess, imgTask, jsTask, cssTask, fontsTask, exportDocs),watchTask);

I even created a netlify.toml file that I have no idea what it does, but found it in a solution, but it still doesn’t work.

# global context
[build]
  publish = "dist"
  command = "gulp build"
# build a preview (optional)
[context.deploy-preview]
  command = "gulp build-preview"
# build a branch with debug (optional)
[context.branch-deploy]
  command = "gulp build-debug"

can you post your package.json please?

{
“name”: “portfolio-code”,
“version”: “1.0.0”,
“description”: “Portfolio 2020”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”,
“build”: “gulp build”,
“build-preview”: “gulp build-preview”
},
“repository”: {
“type”: “git”,
“url”: “git+ssh://git@github.com/jesusrmz19/Portfolio2020.git”
},
“author”: “Jesus Ramirez”,
“license”: “MIT”,
“bugs”: {
“url”: “https://github.com/jesusrmz19/Portfolio2020/issues
},
“homepage”: “https://github.com/jesusrmz19/Portfolio2020#readme”,
“devDependencies”: {
“autoprefixer”: “^9.8.6”,
“cssnano”: “^4.1.10”,
“gulp”: “^4.0.2”,
“gulp-concat”: “^2.6.1”,
“gulp-imagemin”: “^7.1.0”,
“gulp-postcss”: “^9.0.0”,
“gulp-sourcemaps”: “^2.6.5”,
“gulp-terser”: “^1.4.0”
}
}

Hello Perry, did you get a chance to review my package.json file?

Any devDependencies in your package.json will NOT be installed when Netlify automatically run yarn install or npm install at the beginning of the build.

Try making Gulp a dependency rather than dev dependency?