Skip to content

Install Three.js and @three/types

Video Lecture

Install Three.js and @three/types Install Three.js and @three/types

 (Pay Per View)

You can use PayPal to purchase a one time viewing of this video for $1.49 USD.

Pay Per View Terms

  • One viewing session of this video will cost the equivalent of $1.49 USD in your currency.
  • After successful purchase, the video will automatically start playing.
  • You can pause, replay and go fullscreen as many times as needed in one single session for up to an hour.
  • Do not refresh the browser since it will invalidate the session.
  • If you want longer-term access to all videos, consider purchasing full access through Udemy or YouTube Memberships instead.
  • This Pay Per View option does not permit downloading this video for later viewing or sharing.
  • All videos are Copyright © 2019-2025 Sean Bradley, all rights reserved.

Description

After copying the main.ts code from the last lesson, we should see an error indicating,

Cannot find module 'three' or its corresponding type declarations

We can fix this by installing the three library and its related type declarations.

Open the VSCode integrated terminal and execute these commands below.

npm install three --save-dev
npm install @types/three --save-dev

Note

three and @types/three are developed by different teams of people, and won't always be synchronized. If the versions don't match, then we can still continue anyway. Try updating the type declarations again in a few days.

The file ./src/main.ts should now contain no errors.

Occasionally the IDE can be slow to update after installing types. You can press F1, and then select TypeScript: Restart TS Server to force the IDE to update.

Now to restart the project to see it working.

npm run dev

Visit http://localhost:5173/ in the browser.

You should see a multi coloured wireframe cube spinning around in circles.

<>