# Debugging the Portal in VS Code Two independent debug targets: **backend** (server-side SvelteKit code) and **frontend** (client-side Svelte/browser code). Pick from the Run and Debug panel (⇧⌘D). ## Backend (server-side code) Breakpoints work in `+page.server.ts`, `+server.ts`, `$lib/server/**`, `hooks.server.ts`, `src/lib/db.ts`, etc. 1. Run and Debug → **"Backend: Attach to Dev Server"** (or press F5 with it selected). It starts the dev server (Vite with the Node inspector on `:9229`) and attaches automatically. 2. Open a server file, click in the gutter to set a breakpoint, then interact with the app — the breakpoint hits. Alternatives: - **"Backend: Launch Dev Server"** — VS Code starts Vite itself and debugs it directly (no separate task). Good if you want to stop/restart cleanly. - **"Backend: Attach (no server start)"** — attach when the server is already running with the inspector (used by the Full Stack compound). > **Why not `npm run dev`?** `NODE_OPTIONS=--inspect` on `npm` puts the > inspector on the _npm_ process, not Vite, so your breakpoints never hit. The > tasks/configs run `./node_modules/.bin/vite` **directly** so the inspector owns > the process that actually executes the SSR code. ## Frontend (client-side code) Breakpoints work in `.svelte` `