Files
novi-lessons/v2/Les02-OpenCode/Les02-Voorbereiding.md
2026-02-11 13:58:41 +01:00

257 lines
5.0 KiB
Markdown

# Les 2: Voorbereiding (Verplicht!)
**⚠️ BELANGRIJK:** Voltooi deze stappen VOOR Les 2 begint. Zonder deze setup kun je niet meedoen!
**Geschatte tijd:** 20-30 minuten
---
## Checklist
Aan het einde van deze voorbereiding heb je:
- [ ] Node.js geïnstalleerd via NVM
- [ ] Git geïnstalleerd
- [ ] SSH key gegenereerd en toegevoegd aan GitHub
- [ ] Terminal basics begrepen
---
## 1. Node.js installeren via NVM
**Waarom NVM?** NVM (Node Version Manager) laat je makkelijk wisselen tussen Node versies. Veel projecten vereisen specifieke versies.
### Mac / Linux
Open Terminal en voer uit:
```bash
# 1. Installeer NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# 2. Sluit terminal en open opnieuw (of run dit):
source ~/.zshrc # voor zsh (standaard op Mac)
# OF
source ~/.bashrc # voor bash
# 3. Installeer Node 20 (LTS)
nvm install 20
# 4. Gebruik Node 20 als standaard
nvm use 20
nvm alias default 20
# 5. Controleer installatie
node -v # Moet v20.x.x tonen
npm -v # Moet 10.x.x tonen
```
### Windows
**Optie A: NVM voor Windows (aanbevolen)**
1. Download installer: https://github.com/coreybutler/nvm-windows/releases
2. Download `nvm-setup.exe`
3. Installeer (volg wizard)
4. Open **nieuwe** PowerShell of Command Prompt
5. Voer uit:
```powershell
nvm install 20
nvm use 20
node -v # Moet v20.x.x tonen
```
**Optie B: Direct Node.js installeren**
1. Ga naar https://nodejs.org
2. Download LTS versie (20.x)
3. Installeer (volg wizard)
4. Herstart terminal
5. Controleer: `node -v`
---
## 2. Git installeren
### Mac
Git is vaak al geïnstalleerd. Check:
```bash
git --version
```
Als niet geïnstalleerd:
```bash
# Via Homebrew (aanbevolen)
brew install git
# Of download van https://git-scm.com/download/mac
```
### Windows
1. Download van https://git-scm.com/download/windows
2. Installeer (gebruik standaard opties)
3. **Belangrijk:** Kies "Git Bash" als terminal optie
4. Herstart terminal
5. Controleer: `git --version`
### Linux (Ubuntu/Debian)
```bash
sudo apt update
sudo apt install git
git --version
```
---
## 3. SSH Key voor GitHub
**Waarom SSH?** Met SSH hoef je niet steeds je wachtwoord in te voeren bij git push/pull.
### Stap 1: Genereer SSH key
**Mac / Linux / Git Bash (Windows):**
```bash
# Genereer key (vervang met je eigen email!)
ssh-keygen -t ed25519 -C "jouw-email@example.com"
# Druk Enter voor standaard locatie
# Kies wachtwoord of laat leeg (Enter)
```
### Stap 2: Kopieer je public key
**Mac:**
```bash
cat ~/.ssh/id_ed25519.pub | pbcopy
```
**Linux:**
```bash
cat ~/.ssh/id_ed25519.pub
# Selecteer en kopieer handmatig
```
**Windows (Git Bash):**
```bash
cat ~/.ssh/id_ed25519.pub | clip
```
### Stap 3: Voeg toe aan GitHub
1. Ga naar https://github.com/settings/keys
2. Klik "New SSH key"
3. Titel: "Mijn Laptop" (of iets herkenbaars)
4. Plak je key
5. Klik "Add SSH key"
### Stap 4: Test de verbinding
```bash
ssh -T git@github.com
```
Je ziet: `Hi username! You've successfully authenticated...`
**⚠️ Eerste keer:** Je krijgt een vraag over fingerprint. Type `yes`.
---
## 4. Terminal Basics
Je hebt een terminal nodig om met OpenCode te werken. Hier de basics:
### Wat is een terminal?
- **Mac:** Terminal app (in Applications → Utilities)
- **Windows:** PowerShell, Command Prompt, of **Git Bash** (aanbevolen)
- **Linux:** Terminal
### Basis commando's
| Commando | Wat het doet | Voorbeeld |
|----------|--------------|-----------|
| `pwd` | Toon huidige map | `pwd``/Users/tim/projects` |
| `ls` | Toon bestanden in map | `ls` → toont bestanden |
| `cd` | Ga naar map | `cd projects` |
| `cd ..` | Ga map omhoog | `cd ..` |
| `mkdir` | Maak nieuwe map | `mkdir mijn-project` |
### Oefening
Open je terminal en probeer:
```bash
# 1. Waar ben ik?
pwd
# 2. Wat staat hier?
ls
# 3. Ga naar Documents (of andere map)
cd Documents
# 4. Waar ben ik nu?
pwd
# 5. Ga terug
cd ..
```
---
## 5. Controleer alles
Voer deze commando's uit en controleer de output:
```bash
# Node.js versie (moet 20.x.x zijn)
node -v
# npm versie (moet 10.x.x zijn)
npm -v
# Git versie
git --version
# SSH verbinding met GitHub
ssh -T git@github.com
```
**Alles werkt?** ✅ Je bent klaar voor Les 2!
---
## Troubleshooting
### "command not found: nvm"
- Sluit terminal en open opnieuw
- Mac: voeg toe aan `~/.zshrc`: `export NVM_DIR="$HOME/.nvm" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"`
### "Permission denied" bij npm install
- Gebruik `sudo npm install -g ...` (Mac/Linux)
- Of fix npm permissies: https://docs.npmjs.com/resolving-eacces-permissions-errors
### "Permission denied (publickey)" bij GitHub
- Je SSH key is niet goed toegevoegd
- Controleer: `ls ~/.ssh/` - je moet `id_ed25519` en `id_ed25519.pub` zien
- Voeg opnieuw toe aan GitHub
### Windows: Git Bash vs PowerShell
- **Git Bash:** Unix-achtige commando's (`ls`, `cat`, etc.)
- **PowerShell:** Windows commando's
- Tip: Gebruik Git Bash voor consistentie met Mac/Linux
---
## Hulp nodig?
- Stuur bericht via Teams
- Kom 15 minuten eerder naar Les 2 voor hulp
**Tot Les 2!** 🚀