Necesito saber por qué cuando uso el atributo onclick en el archivo HTML funciona bien, pero cuando cambio la etiqueta del script para que sea la identificación del module no funciona y me da este error main is not defined cuando hago clic en el botón
<!--index.html--> <body> <button onclick="main()">test</button> <script type="module" src="./index.js"></script> </body> function main() { const newDev = document.createElement("p"); newDev.textContent = "function works well"; document.body.appendChild(newDev); }