Install OpenCode
Step-by-step install dan verifikasi instalasi.
Install OpenCode
Pertama, pastiin komputer kamu udah siap.
Prasyarat
- Node.js versi 18+ (sudah include npm)
- Terminal (PowerShell di Windows, Terminal di Mac/Linux)
- Internet (buat download package)
Cek Instalasi Node.js
Buka terminal, jalanin:
node --version
npm --version
Harus keluar versi, misal v20.10.0 dan 10.2.3.
Belum Punya Node.js? Install Dulu (Versi LTS)
Windows
Opsi 1: Winget (paling cepat, Windows 10/11)
winget install OpenJS.NodeJS.LTS
Opsi 2: Chocolatey
choco install nodejs-lts
Opsi 3: Manual Download
- Buka nodejs.org
- Klik tombol LTS (bukan Current)
- Download installer
.msi - Jalankan installer, next-next-finish
- Restart terminal setelah install
macOS
Opsi 1: Homebrew (recommended)
brew install node@20
Opsi 2: Manual Download
- Buka nodejs.org
- Klik tombol LTS
- Download installer
.pkg - Jalankan installer
Linux (Ubuntu/Debian)
# Via NodeSource (recommended untuk versi terbaru LTS)
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
# Atau via package manager (versi mungkin lebih lama)
sudo apt update && sudo apt install nodejs npm
Verifikasi Install Node.js
Setelah install, restart terminal lalu cek:
node --version
npm --version
Harus keluar versi LTS (contoh: v20.x.x atau v22.x.x).
Install OpenCode
Jalanin command ini:
npm install -g opencode-ai
Tunggu sampe selesai. Mungkin butuh beberapa menit.
Verifikasi Instalasi OpenCode
opencode --version
Harus keluar versi, misal 0.1.0 atau yang terbaru.
Catatan Windows: Kalau error soal script execution policy, jalanin PowerShell sebagai Administrator trus:
powershellSet-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserLalu coba
opencode --versionlagi.
Troubleshooting Cepat
| Error | Solusi |
|-------|--------|
| opencode: command not found | Restart terminal / tambah npm global bin ke PATH |
| EACCES permission denied | npm config set prefix ~/.npm-global lalu tambah ke PATH |
| Version lama | npm update -g opencode-ai |
| node / npm not found | Install Node.js LTS dulu (lihat atas) |
