Debugging Guide
When things go wrong, use these strategies to identify the root cause.
Dev Server Issues
Section titled “Dev Server Issues”If the dev server behaves unexpectedly (styling broke, infinite reload loop, etc.):
- Stop the server: Press
Ctrl + C. - Clear cache: Run
rm -rf node_modules/.vite. - Restart: Run
pnpm dev.
Debugging Build Issues
Section titled “Debugging Build Issues”Production builds can fail even if the dev server works. This is often due to stricter type checking or missing files.
How to debug:
- Run
pnpm buildlocally. - Read the error log carefully from the top. The first error is usually the root cause.
- Check for “Is not assignable to parameter of type” errors—this indicates a TypeScript mismatch.
Network Debugging
Section titled “Network Debugging”When fetching data from Ghost CMS or other APIs:
- Check the Network Tab: Open Browser DevTools (F12) -> Network.
- Filter by Fetch/XHR.
- Look for red (4xx or 5xx) requests.
- Inspect the Response: Click the request and check the “Response” tab to see the API error message.
VS Code Extensions
Section titled “VS Code Extensions”We recommend these extensions to catch errors early:
- Astro: Syntax highlighting and IntelliSense for
.astrofiles. - ESLint: Real-time linting errors.
- Prettier: Automatic formatting.
- Tailwind CSS IntelliSense: Autocomplete for utility classes.
”It works on my machine”
Section titled “”It works on my machine””If it works locally but fails on Cloudflare Pages:
- Check Node Version: Ensure Cloudflare is using the same Node version (check
.nvmrcorpackage.jsonengines). - Check Environment Variables: Are production secrets set in the Cloudflare dashboard?
- Check Case Sensitivity: Linux (CI/CD) is case-sensitive.
Image.pngandimage.pngare different files. macOS is usually case-insensitive.