ESlint error when importing JS library


I am trying to use the Rellax parallax library in a project, but I’m running into an error when trying to run the code required:
var rellax = new Rellax(’.rellax’);

I receive the following error:

ERROR in ./resources/assets/scripts/main.js
Module build failed: Module failed because of a eslint error. /home/nadal/Web/x/site/web/app/themes/x/resources/assets/scripts/main.js 29:1 error 'rellax' is not defined no-undef 29:14 error 'Rellax' is not defined no-undef ✖ 2 problems (2 errors, 0 warnings)
 @ multi ./resources/assets/build/util/../helpers/hmr-client.js ./scripts/main.js ./styles/main.scss

The JS file is properly imported as I’ve seen the code in the compiled main.js.

Any ideas on how to solve this?

I was a bit too quick to ask for help. I found the solution here: Sage 9 - external Js not defined

So, my solution for anyone else who stumbles upon this page with the same error:

I moved imports and everything from main.js to routes/common.js, and now my common.js looks like this:

// import rellax.js
import Rellax from 'rellax/rellax.min';

export default {
  init() {
    // JavaScript to be fired on all pages
    var rellax = new Rellax('.rellax');
  finalize() {
    // JavaScript to be fired on all pages, after page specific JS is fired