Importing Orbit Controls

Hi there I am trying to import Orbit controls from my node modules but it is giving the error provided in 2nd image.


image

Thank you :smiley:

This who I have my imports

import * as THREE from 'three';
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';

check if the OrbitControls file is in your node modules folder first. if not try

npm install three-orbitcontrols

you can’t import from node_modules, that folder does not exist in production or from the bundlers perspective. the whole point of it is that when you import something, say “three”, it resolves it according to your local node_modules folder and then includes that bit in your bundle.

also you are missing the “.js” extension on the import

I am pretty sure this is the right solution but for some reason simply importing after npm install <> does not seem to work. It might be probably because I did not set things up right from the start.

adding the .js extension worked. Thank you, everyone :smiley: