Wajib#4

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:

bash
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)

powershell
winget install OpenJS.NodeJS.LTS

Opsi 2: Chocolatey

powershell
choco install nodejs-lts

Opsi 3: Manual Download

  1. Buka nodejs.org
  2. Klik tombol LTS (bukan Current)
  3. Download installer .msi
  4. Jalankan installer, next-next-finish
  5. Restart terminal setelah install

macOS

Opsi 1: Homebrew (recommended)

bash
brew install node@20

Opsi 2: Manual Download

  1. Buka nodejs.org
  2. Klik tombol LTS
  3. Download installer .pkg
  4. Jalankan installer

Linux (Ubuntu/Debian)

bash
# 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:

bash
node --version
npm --version

Harus keluar versi LTS (contoh: v20.x.x atau v22.x.x).


Install OpenCode

Jalanin command ini:

bash
npm install -g opencode-ai

Tunggu sampe selesai. Mungkin butuh beberapa menit.


Verifikasi Instalasi OpenCode

bash
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:

powershell
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Lalu coba opencode --version lagi.


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) |


Next: Jalankan OpenCode dari Terminal