Node.js, pnpm & TypeScript
Setup Node.js, pnpm, Bun, dan TypeScript. Version management dan konfigurasi runtime untuk development.
Phase 3: Language & SDKs
"Gunakan version manager, hindari install global."
Node.js
Node.js adalah runtime utama untuk project ini. Minimum version: 18.
# Install nvm
brew install nvm
# Tambahkan ke shell config
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc
echo '[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"' >> ~/.zshrc
source ~/.zshrc
# Install Node.js 18
nvm install 18
nvm use 18
nvm alias default 18
# Verifikasi
node -v # v18.x.xbrew install node
# Verifikasi
node -v # v22.x.x (latest)# fnm = Fast Node Manager (Rust-based, lebih cepat dari nvm)
brew install fnm
# Tambahkan ke shell
echo 'eval "$(fnm env --use-on-cd)"' >> ~/.zshrc
source ~/.zshrc
# Install & gunakan Node 18
fnm install 18
fnm use 18
fnm default 18
# Verifikasi
node -v # v18.x.xJangan install Node.js secara global tanpa version manager. Gunakan nvm atau fnm agar bisa switch versi dengan mudah antar project.
pnpm
pnpm adalah package manager yang digunakan di project ini. Version yang tepat sangat penting untuk lockfile compatibility.
Install
npm install -g pnpm@10.28.2
# Verifikasi
pnpm -v # 10.28.2# Corepack sudah built-in di Node.js >= 16
corepack enable
corepack prepare pnpm@10.28.2 --activate
# Verifikasi
pnpm -v # 10.28.2pnpm Commands yang Sering Dipakai
| Command | Description |
|---|---|
pnpm install | Install semua dependencies |
pnpm add <pkg> | Tambah dependency baru |
pnpm add -D <pkg> | Tambah dev dependency |
pnpm remove <pkg> | Hapus dependency |
pnpm dev | Jalankan dev server |
pnpm build | Build untuk production |
pnpm dlx <pkg> | Jalankan package tanpa install |
Bun
Bun digunakan sebagai script runner (menjalankan TypeScript scripts di Makefile).
# Install
brew install oven-sh/bun/bun
# Verifikasi
bun -v # 1.x.xKenapa Bun?
- Menjalankan
.tsfiles langsung tanpa compile step - Digunakan di
Makefileuntuk generate OpenAPI docs:generate-openapi: bun run ./scripts/generate-docs.ts
TypeScript
TypeScript di-install sebagai dev dependency project (bukan global).
Konfigurasi
File tsconfig.json sudah ada di root project:
Prop
Type
Path Aliases
Project ini menggunakan path aliases untuk import yang bersih:
// Daripada:
import { source } from "../../../lib/source";
// Gunakan:
import { source } from "@/lib/source";| Alias | Maps To | Usage |
|---|---|---|
@/* | ./* | Semua file dari root |
@/.source | .source | Generated content (Fumadocs) |
Environment Variables
File .env
# Copy template
cp .env.example .env| Variable | Required | Description |
|---|---|---|
AUTH_SECRET | Ya | Secret untuk NextAuth JWT encryption |
NEXT_PUBLIC_APP_URL | Tidak | URL production site |
Generate Secret
# Generate AUTH_SECRET
openssl rand -base64 32All Dependencies
Production Dependencies
next@16.0.10 React framework
react@19.2.0 UI library
react-dom@19.2.0 React DOM
fumadocs-core@16.0.6 Documentation engine
fumadocs-mdx@13.0.3 MDX processing
fumadocs-openapi@9.7.2 OpenAPI docs
fumadocs-ui@16.0.6 Documentation UI
next-auth@5.0.0-beta.30 Authentication
ai@5.0.86 Vercel AI SDK
tailwind-merge@3.3.1 Tailwind class merging
zod@4.1.12 Schema validation
shiki@3.14.0 Syntax highlighting
katex@0.16.28 Math rendering
mermaid@11.12.1 Diagram rendering
lucide-react@0.548.0 Icon libraryDev Dependencies
typescript@5.9.3 Type checking
eslint@9.38.0 Linting
prettier@3.8.1 Formatting
tailwindcss@4.1.16 CSS framework
postcss@8.5.6 CSS processing
tsx@4.20.6 TS script runnerCara Uninstall
Last updated on