Continued Trials: Build Errors on Cloudflare Pages

📅 2025-08-10 ✍️ prosalmontech #開発ノート#Cloudflare#build error

ONGOING TRIALS: BUILD ERRORS ON CLOUDFLARE PAGES

Although the Git push succeeded, deployment on Cloudflare Pages failed. I faced a series of errors one after another.

  1. SYNTAX ERRORS

  2. A JavaScript syntax error occurred due to an apostrophe inside a string, such as 'App's'.

  3. Forgetting to close a JSX tag.

Solution: Wrap strings in double quotes, add missing closing tags, and fix basic syntax issues.

  1. TYPESCRIPT TYPE ERRORS

  2. getBlogPost could return null, but the null check was insufficient.

  3. Initialized an array with useState([]) and then tried to assign a Contentful Entry type to it.

  4. console.log was left inside JSX.

  5. A number was passed to setAttribute.

Solution: Strengthen null checks, explicitly set the type like useState[]>([]), remove console.log, and use String() for type conversion.

  1. CLOUDFLARE PAGES EDGE RUNTIME ERROR

  2. The following routes were not configured to run with the Edge Runtime: ...

Solution: Add export const runtime = 'edge'; at the top of the page.tsx file.

Since blog/[lang]/tags/[tag]/page.tsx did not exist, a placeholder file was created with runtime = 'edge' added.

  1. CLOUDFLARE PAGES NODE.JS COMPATIBILITY ERROR

  2. no nodejs_compat compatibility flag set

Solution: In the Cloudflare Pages dashboard, go to [Settings] → [Functions] → [Compatibility Flags], add nodejs_compat, and enable it.

LESSONS LEARNED

After overcoming this long battle, the joy of finally seeing the site display correctly was truly special.
I hope this article will help someone else struggling with the same errors.

🚀 prosalmontech ポートフォリオ

SatViewer3D、QuakeViewer3D、NihongoChatAI、JPQuizなど、開発中のアプリ・Webサービスを公開中!

トップページでプロダクトを見る