Install with NPM
NPM METHOD
Best for:
- Real projects
- React / Next.js
- Large applications
- Clean & modular code
What is NPM?
NPM = Node Package Manager
It installs libraries locally in your project.
Setup Steps
Step 1: Install Node.js
Download from: https://nodejs.org
Check installation:
node -v npm -v
Step 2: Create project
mkdir three-project cd three-project npm init -y
Step 3: Install Three.js
npm install three
Step 4: Install a bundler (VERY IMPORTANT)
Three.js (NPM) needs a bundler like:
- Vite
👉 Use Vite (simple and fast)
npm create vite@latest
Then:
cd your-project npm install npm run dev
Step 5: Import Three.js
import * as THREE from 'three';
Pros of NPM
- Clean modular code
- Easy to scale
- Works with React / Next.js
- Better performance control
- Industry standard
Cons of NPM
- Setup required
- Needs Node.js knowledge
- Slightly complex for beginners