I have an HTML file and a JavaScript module. The JavaScript module exports a function, which I want to call in the HTML file.
index.html
<html>
<head>
<script type="module" src="app.js"></script>
</head>
<body>
<button onclick="greet()">Greetings from module</button>
</body>
</html>
index.js
function greet() {
alert('Hello');
}
When Greetings from module button is clicked, the following error is thrown:
Uncaught ReferenceError: greet is not defined
at onclick
Note: app.js has to be a marked as a module.