SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON at JSON.parse (<anonymous>)

I had the same problem.
I tried to load .glb model in a react project (React version: ^18.2.0).

The solution for me was to insert the model to the public folder as mentioned before.
When doing so and using it like this:

  const modelLoader = new GLTFLoader();
  modelLoader.load("/assets/models/myModel.glb", ...rest of the code...

Everything works just fine.

P.S

  • Make sure your camera is in the right position and can see the model
  • Make sure you model is not too small or not too big
1 Like