ビルドに使う Node のバージョンを固定する(予防) - #26
Merged
Merged
Conversation
reform で Cloudflare Pages のビルドが Node 12.18.0(Build Image v1 の既定) で実行されて失敗していた。このリポジトリも同じ構成で、Node の指定が どこにも無いため同じ問題が起きうる。 依存が要求する Node: sass@1.102.0 >=20.19.0 chokidar@5.0.0 >= 20.19.0 readdirp@5.0.0 >= 20.19.0 いまは動いているが、Build Image の既定が変わるか依存が上がると壊れる。 web/.node-version と engines.node で明示的に固定しておく。 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Deploying openbookcamera with
|
| Latest commit: |
362a97a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4a22eaf1.openbookcamera.pages.dev |
| Branch Preview URL: | https://fix-pin-node-version.openbookcamera.pages.dev |
.node-version で 24 を指定しても、Cloudflare 側の設定(Build Image や ルートディレクトリ)次第では読まれず、別の Node でビルドされうる。 そのとき今の構成では npm ci が警告を出すだけで先に進んでしまう。 reform では Cloudflare が Node 12 でビルドし続けていたのに、 古い成果物が配信され続けたため 7 か月気づかなかった。 engine-strict=true にしておけば engines.node を満たさない Node では EBADENGINE で止まるので、静かに壊れる代わりにビルドが失敗して分かる。 Node 24 でクリーンインストールとビルドが通ることを確認済み。
一時的に >=24.0.0 にして Cloudflare が本当に Node 24 を使っているか 確認した。web/.node-version が読まれていることが分かったので戻す。
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
このPRでやること
ビルドに使う Node のバージョンを
web/.node-versionとengines.nodeで固定します。いまは正常にビルドできています。予防のための変更です。
なぜ必要か
reformで Cloudflare Pages のビルドが失敗し、原因はNode 12.18.0(Build Image v1 の既定)で実行されていたことでした。
このリポジトリも同じ構成(Cloudflare Pages + Node ビルド)で、
Node のバージョン指定がどこにもありません(
.node-version/.nvmrc/enginesすべて無し)。依存はすでに新しい Node を要求しています。
sass@1.102.0>=20.19.0chokidar@5.0.0>= 20.19.0readdirp@5.0.0>= 20.19.0現在たまたま動いているのは、Cloudflare 側の設定が合っているためです。
Build Image の既定が変わるか、Dependabot が依存をさらに上げると壊れます。
reformはまさにその経路で壊れました(Dependabot が依存を上げ、Cloudflare が Node 12 のままだった)。変更内容
web/.node-version(新規)24web/package.json"engines": {"node": ">=20.19.0"}.node-versionは Cloudflare Pages が読み取ります。enginesがあると、手元で古い Node を使ったときにも警告が出ます。確認したこと
npm ci && npm run buildが通るweb/build/に HTML・CSS・画像がすべて生成される(parcel のビルド完了を確認)補足
reformでは Build Image を v1 → v3 に切り替えました。このリポジトリの Build Image が v1 のままであれば、同様に v3 への切り替えをお勧めします。