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
1 Like

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.

1 Like

also you are missing the โ€œ.jsโ€ extension on the import

1 Like

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: