HTML onClick node js function loading ‘require’ another module in the onClick function not working

I have code like:

<!DOCTYPE html>
<html>
<body>

<h1>HTML DOM Events</h1>
<h2>The onclick Event</h2>

<p>The onclick event triggers a function when an element is clicked on.</p>
<p>Click to trigger a function that will output "Hello World":</p>

<button onclick="myFunction()">Click me</button>

<p id="demo"></p>

<script>
function myFunction() {
  const os = require('os')
  document.getElementById("demo").innerHTML = "Hello World";
}
</script>

</body>
</html>

The code works when I remove:
const os = require('os')

I however need to load a module in this function that is being used for the onClick event.

Please note that I am a noob to javascript.
Any and all assistance / guidance will be much appreciated.

Thanks.