Categories
JavaScript Answers

How to fix Uncaught Error: Cannot find module ‘jquery’ with Node Electron app?

Spread the love

To fix Uncaught Error: Cannot find module ‘jquery’ with Node Electron app, we need to add the jQuery script into our HTML file.

For instance, we write

<!DOCTYPE html>
<html>
  <head></head>

  <body>
    <h1>Hello World!</h1>
  </body>

  <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>

  <script>
    window.jQuery = window.$ = jQuery;

    $(document).ready(function () {
      console.log("jQuery is loaded");
    });
  </script>
</html>

to add the jQuery script with

<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.