Recently, I started using Webpack and I was requiring jQuery using ‘require(“jquery”)’ and then I started getting errors in my app like so:
1 |
jQuery not defined or $ not defined |
Then I found this piece here which explained that Webpack doesn’t set any global variables, so you have to set them yourself. So I did this:
1 2 |
window.jQuery = require('jquery'); window.$ = window.jQuery; |
Happily this solved my issues.