Support » Developing with WordPress » NODE | Require is not defined(Uncaught Reference Error)

  • kesking7

    (@kesking7)


    I’ve been developing a page with glide.js in WordPress. After I’ve included the needed JS Files in functions.php, I have seen that in my console it says “Uncaught ReferenceError: require is not defined.” What can I do to make the site that works on the client/side browser either? Here is the main.js file’s code.

    Thanks in advance,

    document.addEventListener("DOMContentLoaded", () => {
        new Glide(".glide", {
            type: "carousel",
            startAt: 0,
            animationTimingFunc: "ease-in-out",
            gap: 100,
            perView: 3
        }).mount();
    });
    

    Here is the link to the post in StackOverflow.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Joy

    (@joyously)

    This is not a WordPress question.

    Moderator bcworkz

    (@bcworkz)

    Regarding your SO post “Mismatched anonymous define() module”, see https://requirejs.org/docs/errors.html#mismatch
    Scripts using define() cannot be enqueued the usual WP way, they need to be loaded through the require.js API. This may not be the cause of your specific problem, but it’s a common cause. Read the linked doc for other possible causes.

    Joy is correct, this is not a WP issue. But FYI all the same since I happened to stumble across the linked doc.

    Thread Starter kesking7

    (@kesking7)

    Hi,

    Thank you for your assist. I’ve already checked the documentation link. Since I’ve started getting into WordPress theme development recently, I thought that might be related to the way of how dynamic websites functioning. Because, when I tried to implement the function on the static website all was good.

    Have a good one!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.