0

I'm using gulp 4 in my project with bootstrap 5 when I call the BS from node_modules the js did not work as I expected it show me this error message in my console.

Uncaught ReferenceError: require is not defined

here is my app.js file:

var bootstrap = require("../../node_modules/bootstrap/dist/js/bootstrap.bundle");

here is my gulpfile.js file:

const { src, dest, watch, series, parallel } = require("gulp");
const terser = require("gulp-terser");
const babel = require("gulp-babel");
const browsersync = require("browser-sync").create();

...

function compileJS() {
    return src("src/js/app.js", { sourcemaps: true })
        .pipe(babel())
        .pipe(terser())
        .pipe(dest("src/assets/js", { sourcemaps: "." }));
}

...

the SASS files work well but the js no I got that error message.

jhon-jhones
  • 455
  • 1
  • 13
  • 27

0 Answers0