[Script Loader] SyntaxError: Cannot use import statement outside a module code example
Example 1: SyntaxError: Cannot use import statement outside a module
Node.js >= v13
Save the file with .mjs extension, &
Add { "type": "module" } in the nearest package.json.
(run npm init to create package.json)
Example 2: Uncaught SyntaxError: Cannot use import statement outside a module three.js
<script src="/node_modules/three/examples/jsm/controls/OrbitControls.js"></script>
<script src="/node_modules/three/examples/js/controls/OrbitControls.js"></script>