2

I have a laravel project (webpack/laravel mix), and I would like to use the ekko-lightbox plugin. I installed it with npm, but it doesn't work. I always got the following error:

Uncaught ReferenceError: jQuery is not defined at Object../node_modules/ekko-lightbox/dist/ekko-lightbox.min.js

Of course I imported the jquery and the ekko-lightbox also, but it doesn't work. Here is my js:

import 'slick-carousel';
import 'ekko-lightbox';
import $ from 'jquery';
window.$ = window.jQuery = $;

The slick is working fine, but the ekko-lightbox doesn't want to work.

What I should to do? What do I do wrong?

Thanks for the help in advance!

Mate
  • 61
  • 4

1 Answers1

0

Fixing error: jquery not found when using ekko-lightbox with Webpack

The issue is because jquery isnt accessible in the imported ekko-lighbox, so

Append the below to your webpack.config.js:

  plugins: [
    new webpack.ProvidePlugin({
      $: 'jquery',
      jQuery: 'jquery'
    })
  ]

And in your JS file, remove all the jquery related imports as webpack automatically loads modules instead of having to import or require them everywhere.

import 'slick-carousel';
import 'ekko-lightbox';
// removed all jquery related imports
RICHARD ABRAHAM
  • 2,218
  • 20
  • 26