javascript – How to import three.module.js


I’m looking at this three.js cubemap example, and it runs fine in my browser when loaded from that page.

After much strain to find and download the files – it does not run?

What am I doing wrong, with this “module” stuff?

I got it to work by changing:


<script type="module">
import * as THREE from 'three.module.js';
...

Into:

<script src="https://gamedev.stackexchange.com/three.js"></script>
<script>
...

Can anyone explain how to properly import three.module.js? Why is this change necessary when I run the project on my machine?