Skip to content

Node 22.x / npm 10.x を .nvmrc と engines で固定 - #5849

Merged
TinyKitten merged 1 commit into
devfrom
feature/enforce-node-npm-versions
Apr 21, 2026
Merged

TinyKitten merged 1 commit into
devfrom
feature/enforce-node-npm-versions

Conversation

@TinyKitten

@TinyKitten TinyKitten commented Apr 21, 2026 •

Copy link
Copy Markdown
Member

概要

CI は Node 22 / npm 10、ドキュメント (CLAUDE.md / README / copilot-instructions) も同じバージョンを要件として明記しているが、機械的な強制が一切無く、Node 24 / npm 11 ローカル環境で npm install すると lockfile が書き換わって CI (npm 10) の npm ci が Missing: ... from lock file で失敗する事故が発生した(#5847 で実際に踏んだ)。今回の変更で、CI と同じバージョン以外では npm install 自体をブロックするようガードを導入する。

変更の種類

  • バグ修正
  • 新機能
  • リファクタリング
  • ドキュメント
  • CI/CD
  • その他

変更内容

  • .nvmrc を追加し 22 を記載(nvm / fnm / asdf / mise 等が自動で Node 22 に切り替え)
  • package.json の engines に { "node": "22.x", "npm": "10.x" } を追加(npm install 時に不一致を検出)
  • .npmrc を追加し engine-strict=true を設定(engines 不一致を警告ではなくエラー扱いにして install を停止)
  • README.md の Prerequisites 節に .nvmrc と engine-strict の存在を追記

テスト

  • npm run lint が通ること(Node 22 / npm 10.9.7)
  • npm test が通ること(148 suites / 1398 tests、Node 22 / npm 10.9.7)
  • npm run typecheck が通ること(Node 22 / npm 10.9.7)
  • Node 24 / npm 11 環境で npm install を実行すると EBADENGINE で停止すること
  • Node 22 / npm 10 環境では npm install が通り、lockfile 差分は engines ブロック追記のみであること(依存版の書き換えが発生しないこと)

関連Issue

#5847 で顕在化した lockfile drift 事故の再発防止。

スクリーンショット(任意)

Summary by CodeRabbit

Chores

  • プロジェクト環境の一貫性を確保するため、Node.js 22.x および npm 10.x のバージョン要件を設定しました。
  • NVM を使用した Node.js バージョン管理の設定を追加し、開発環境を統一しました。
  • npm のバージョン厳密チェックを有効化し、サポートされていないバージョンのインストールを防ぎました。

@TinyKitten TinyKitten self-assigned this Apr 21, 2026
@coderabbitai

coderabbitai Bot commented Apr 21, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e3ecd9e8-a4b7-4c55-a891-d9de828fe73f

📥 Commits

Reviewing files that changed from the base of the PR and between 65e9fe3 and 0a2ffa7.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • .npmrc
  • .nvmrc
  • README.md
  • package.json

📝 Walkthrough

Walkthrough

プロジェクトの Node.js と npm バージョン管理を確立するための設定ファイルとドキュメントを追加しました。.nvmrc で Node 22 を指定し、package.json の engines フィールドで要件を定義し、.npmrc で厳密な検証を有効化します。

Changes

Cohort / File(s) Summary
バージョン管理設定
.npmrc, .nvmrc, package.json
Node.js 22.x と npm 10.x の環境要件を定義。engine-strict=true で npm が要件を厳密に検証するよう設定。
ドキュメント更新
README.md
前提条件セクションを更新し、.nvmrc での Node バージョン ピニング、nvm use の使用、npm 10.x が Node 22 にバンドルされていること、engines による検証を明記。

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 バージョンを統一する時が来た
.nvmrc と engines で調和し
npm は厳しく、チームは安心
設定ファイルが繋ぐ信頼の絆
皆が同じ環境で働く喜び

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは Node 22.x / npm 10.x のバージョン固定を .nvmrc と engines で実施するというPRの主要な変更内容を明確に記述しており、変更内容と完全に関連している。
Description check ✅ Passed PRの説明は推奨テンプレートの構造に従い、概要、変更の種類、変更内容、テスト、関連Issueのセクションがすべて適切に記入されている。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/enforce-node-npm-versions

Comment @coderabbitai help to get the list of available commands and usage tips.

@TinyKitten
TinyKitten merged commit c2e0ac5 into dev Apr 21, 2026
6 checks passed
@TinyKitten
TinyKitten deleted the feature/enforce-node-npm-versions branch April 21, 2026 05:15
@TinyKitten TinyKitten mentioned this pull request May 9, 2026
7 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant