Q:

Uncaught SyntaxError: Cannot use import statement outside a module three.js

# there are a lot of possible solutions for this problem

1) change es6 to es5 import
import package from 'packageName'; -> 
var package = require('packageName');

2) change file extension (.js -> .mjs)

3) add "type: module" in package.json

4) add 'type="module"' in script tag
1
//If you already put this and still error.
<script src="/node_modules/three/examples/jsm/controls/OrbitControls.js"></script>
//Try changing jsm to js
<script src="/node_modules/three/examples/js/controls/OrbitControls.js"></script>
0

New to Communities?

Join the community