K
K
Kerich92022-03-31 11:24:06
JavaScript
Kerich9, 2022-03-31 11:24:06

Gulp won't start ("'build' errored after"), what could be wrong?

Guys, hello everyone!

Downloaded a very cool javascript course. And the person uses the assembly, I try to start, knocks out errors.

'build' errored after 3.26s
[11:17:19] 'default' errored after 3.27s

"use strict";

const gulp = require("gulp");
const webpack = require("webpack-stream");
const browsersync = require("browser-sync");

const dist = "./dist/";

gulp.task("copy-html", () => {
    return gulp.src("./src/index.html")
                .pipe(gulp.dest(dist))
                .pipe(browsersync.stream());
});

gulp.task("build-js", () => {
    return gulp.src("./src/js/main.js")
                .pipe(webpack({
                    mode: 'development',
                    output: {
                        filename: 'script.js'
                    },
                    watch: false,
                    devtool: "source-map",
                    module: {
                        rules: [
                          {
                            test: /\.m?js$/,
                            exclude: /(node_modules|bower_components)/,
                            use: {
                              loader: 'babel-loader',
                              options: {
                                presets: 
                              }
                            }
                          }
                        ]
                      }
                }))
                .pipe(gulp.dest(dist))
                .on("end", browsersync.reload);
});

gulp.task("copy-assets", () => {
    return gulp.src("./src/assets/**/*.*")
                .pipe(gulp.dest(dist + "/assets"))
                .on("end", browsersync.reload);
});

gulp.task("watch", () => {
    browsersync.init({
    server: "./dist/",
    port: 4000,
    notify: true
    });
    
    gulp.watch("./src/index.html", gulp.parallel("copy-html"));
    gulp.watch("./src/assets/**/*.*", gulp.parallel("copy-assets"));
    gulp.watch("./src/js/**/*.js", gulp.parallel("build-js"));
});

gulp.task("build", gulp.parallel("copy-html", "copy-assets", "build-js"));

gulp.task("build-prod-js", () => {
    return gulp.src("./src/js/main.js")
                .pipe(webpack({
                    mode: 'production',тзь,
                    output: {
                        filename: 'script.js'
                    },
                    module: {
                        rules: [
                          {
                            test: /\.m?js$/,
                            exclude: /(node_modules|bower_components)/,
                            use: {
                              loader: 'babel-loader',
                              options: {
                                presets: 
                              }
                            }
                          }
                        ]
                      }
                }))
                .pipe(gulp.dest(dist));
});

gulp.task("default", gulp.parallel("watch", "build"));

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Shipin, 2022-04-01
@Kerich9

Run gulp copy-html, gulp copy-assets, gulp build-js and gulp build separately.
If any of these commands gives an error, it means that the error is contained in this command, it will be easier to "dance" from it.
Since we do not know anything about the structure of the project, nor about the presence of certain installed modules. Simply put, we know nothing but the gulpfile.js script

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question