Import * as THREE from “three” throws console error

I’ve had some sorta issue with my website where it says line one is wrong is some way… I’m using an import map…but I don’t think that’s the issue…help would be appreciated.

Could you post your code or a GitHub repository with the code?

Yea…I got it working…but for future reference to people I will explain what caused the error.

Always Check INDENTATIONS… my script was indented incorrectly and caused an error apparently…not sure what the error message was about.

Check out the website at ThreeJs

not sure why but you’re importing three from a cdn in your js…


as well as using import maps for the same thing…
image
you’re essentially loading the same thing twice… the appropriate way to import with import maps in your main.js file would be…

import * as THREE from "three";
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
2 Likes

When I did that it gave me the error and I never fixed it…thanks for the heads up