As @Bergi mentioned in the comment, adding type="module"
to the main.js
import line in the HTML solved the issue. All is working now. I.e.
<script type="module" src="https://stackoverflow.com/questions/47632562/assets/js/main.js">
Thanks to all of you who responded and tried to help.