title: Uncaught ReferenceError: require not defined (electron)
body: <p>I am trying to create a quote widget on electron. For renderer process, I created index.js and coded like below</p>
  
  <pre><code>console.log('from renderer');
  
  var request = require('request');
  const electron = require('electron');
  
  
  var url ="https://quotesondesign.com/wp-json/wp/v2/posts/?orderby=rand&amp;_="+rnd;
  
  request(url, function(error, response, body) {
      if(error)
      {
          document.getElementById("quote").innerHTML = 'Unable to fetch the quote plaese check the network connection';
          return;
      }
      let bodyJSON = JSON.parse(body);
      console.log(bodyJson);
      let randomQuote = bodyJSON[0]["content"]["rendered"];
      document.getElementById("quote").innerHTML = randomQuote;
  });
  </code></pre>
  
  <p>And index.html has </p>
  
  <pre><code>&lt;div id="quote"&gt;
  
  &lt;/div&gt;
  &lt;script src="index.js"&gt;
      // require ('index.js');
  &lt;/script&gt;
  </code></pre>
  
  <p>If I use <code>require ('index.js');</code> in <code>script</code> tag, it doesn't work. So I used <code>src="index.js"</code>. Now renderer process works but on console, it shows <code>"Uncaught ReferenceError: require is not defined at index.js:3"</code>
  My 1st query is why <code>require ('index.js');</code> on <code>script</code> tag doesn't work on <code>index.html</code>
  and 2nd query is how to fix the <code>Uncaught ReferenceError</code> problem on <code>index.js</code>
  My electron version is v8.2.0 and node version is v12.16.1 and dependencies on <code>package.json</code> are as follows:</p>
  
  <pre><code>"dependencies": {
          "request": "^2.88.2",
          "require": "^2.4.20"
      }
  </code></pre>
  
  <p>Anyone help me please. Thanks in advance.</p>