開発メモ
Nuxt 2をCloudflareにデプロイしたらwranglerエラーで失敗した
結論
Nuxt 2プロジェクトをCloudflareにデプロイする場合、Cloudflare Pages + SSG(静的サイト生成) を使う。
- Build command:
npm run generate - Build output directory:
dist - Deploy command: 不要(Pagesが自動デプロイ)
npx wrangler deployはCloudflare Workers用のコマンドであり、Nuxt 2のSSRビルド出力には対応していない。
発生したエラー
特に設定せずNuxt 2プロジェクトをCloudflareにデプロイしたところ、以下のエラーが発生した。
✘ [ERROR] Missing entry-point to Worker script or to assets directory
ビルドログの分析
ビルド全体の流れを見ると、実はビルド自体は成功している。
2026-01-06T23:34:51.888Z [info] Production build
2026-01-06T23:38:52.405Z [info] Ready to run `nuxt start`
2026-01-06T23:38:52.726Z Success: Build command completed
問題はデプロイコマンドで発生した。
2026-01-06T23:38:52.999Z Executing user deploy command: npx wrangler deploy
2026-01-06T23:39:04.539Z ✘ [ERROR] Missing entry-point to Worker script or to assets directory
原因
wrangler deployはCloudflare Workers用のデプロイコマンドだ。一方、Nuxt 2のnuxt buildはSSR(サーバーサイドレンダリング)用のビルドを生成する。Workersは静的アセットまたはWorkerスクリプトを期待するため、SSRビルドの出力形式とは互換性がない。
つまり、ビルド方式とデプロイ先のミスマッチが原因。
解決策
Cloudflare Pagesを使う場合
Nuxt 2で静的サイト生成(SSG)を行い、Cloudflare Pagesにデプロイする。
Cloudflare Pagesの設定:
| 項目 | 値 |
|---|---|
| Build command | npm run generate |
| Build output directory | dist |
package.jsonにgenerateスクリプトを追加:
{
"scripts": {
"generate": "nuxt generate"
}
}
Cloudflare Workersを使いたい場合
Nuxt 3にアップグレードし、Nitroのcloudflare-pagesプリセットを使用する。Nuxt 3はNitroエンジンを採用しており、Cloudflare Workers/Pagesへのネイティブデプロイをサポートしている。
補足:ログ中の警告について
ビルドログには多くの警告が出ていた。
npm warn deprecated [email protected]: Nuxt 2 has reached EOL and is no longer actively maintained.
npm warn deprecated [email protected]: Vue 2 has reached EOL and is no longer actively maintained.
85 vulnerabilities (14 low, 30 moderate, 37 high, 4 critical)
Nuxt 2とVue 2はEOL(サポート終了)であり、セキュリティアップデートも提供されていない。長期的にはNuxt 3への移行を検討すべき。