0

I'm using Symfony 4.3.3 with webpack-encore-bundle v1.6.2 to develop website. When trying to add wow.js to the front-end, I'm facing with this error:

Uncaught ReferenceError: WOW is not defined

I ran npm install --save wowjs to install this package. Then import the library in the app.js as follow:

import WOW from 'wowjs/dist/wow.min.js';

After using yarn encore dev public files successfully created in output folder of webpack.

new WOW().init(); in main.js file arises the above error.

So, What's the correct way of doing that or basically I must do more stuff to have this working?

Thanks

Mahdi
  • 664
  • 3
  • 15
  • 35
  • Quick and dirty is something like this, right after your import: window.WOW = WOW; – Dimitris Sep 05 '19 at 10:32
  • Thanks, @Dimitris, I did it and now it says `wowjs_dist_wow_min_js__WEBPACK_IMPORTED_MODULE_3___default.a is not a constructor` – Mahdi Sep 05 '19 at 10:42
  • Something like: const WOW = require('wowjs'); window.wow = new WOW.WOW({ live: false }); – Dimitris Sep 06 '19 at 09:04

1 Answers1

0

Option 1:

import { WOW } from 'wowjs'
window.WOW = WOW;

Option 2:

window.WOW = require('wowjs').WOW;
Dharman
  • 30,962
  • 25
  • 85
  • 135