I am trying to build a WordPress site with bootstrap 4 as a dependency using npm and gulp but because bootstrap requires jQuery, I kept on getting this error when trying to run gulp:
Error: Cannot find module 'jquery'
I installed popper
and bootstrap
using gulp and have added the following lines to my gulpfile.js:
var gulp = require('gulp');
var sass = require('gulp-sass');
var popperjs = require('popper.js');
var bootstrap = require('bootstrap');
gulp.task('sass', function(){
return gulp.src(['node_modules/bootstrap/scss/bootstrap.scss', './sass/**/*.scss'])
.pipe(sass())
.pipe(gulp.dest('./'))
});
gulp.task('js', function(){
return gulp.src(['node_modules/popper.js/dist/popper.min.js', 'node_modules/bootstrap/dist/js/bootstrap.min.js', './js/*.js'])
.pipe(gulp.dest('./js'))
});
gulp.task('watch', function(){
gulp.watch('./sass/**/*.scss', ['sass']);
gulp.watch('./js/*.js', ['js']);
});
gulp.task('default', ['sass', 'js', 'watch']);
I initially tried installing jQuery via npm which caused a different error ( Using gulp to install jquery & bootstrap4 returns undefined property error ) but then I remembered that Wordpress has jQuery included with the cms so I removed the npm-installed jQuery and trying to find out how to make bootstrap utilise the WordPress jQuery instead.
So tldr: How do I link my Bootstrap module to the in-build Wordpress jQuery in:
/wp-include/js/jquery.js