Conversation
Fixes the npm bug where rollup's native binaries are not correctly installed when using GitHub Actions cache. Running npm rebuild after npm ci ensures optional dependencies are properly rebuilt. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add a separate workflow to test the release process on the develop branch without actually publishing. This allows us to verify the npm rebuild fix and the full release pipeline before merging to main. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This reverts commit cbb2298.
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Code ReviewOverviewThis PR addresses a rollup module error during the release workflow by adding an explicit rollup installation step and updating the Node.js engine requirement. 🔴 Critical Issues1. Breaking Change Without Proper Versioning (High Priority)Location: The Node.js engine requirement changed from Issues:
Recommendation:
2. Workaround Without Root Cause Analysis (High Priority)Location: The workflow now removes and reinstalls rollup, which suggests a deeper issue: - name: Install rollup with native binaries
run: |
rm -rf node_modules/rollup
npm install rollup --no-saveIssues:
Questions:
Recommendation:
|
|
🎉 This PR is included in version 1.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 0.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
GitHub Actions でのビルドエラー解決
問題の概要
GitHub Actions の CI 環境で
npm run buildを実行すると、以下のエラーが発生していました:Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to optional dependencies (npm/cli#4828).
根本原因
tsup が rollup に依存している
npm の既知のバグ
package-lock.jsonwhen reinstalling withnode_modulespresent npm/cli#4828Linux 固有のネイティブバイナリが欠損
@rollup/rollup-linux-x64-gnuというプラットフォーム固有のパッケージがインストールされていなかった試行した解決策
❌ 失敗した対策
run: npm rebuild
run: |
npm ci
npm install
"devDependencies": {
"rollup": "^4.54.0",
...
}
✅ 成功した解決策
rollup を削除して再インストール
name: Install dependencies
run: npm ci
name: Install rollup with native binaries
run: |
rm -rf node_modules/rollup
npm install rollup --no-save
解決策の詳細
実装方法
.github/workflows/release.yml に以下のステップを追加:
run: |
rm -rf node_modules/rollup
npm install rollup --no-save
動作原理
- この時、npm が optional dependencies を正しく解決してインストールする
- --no-save フラグで package.json への書き込みを防ぐ
なぜこれで解決するのか
最終的なワークフロー構成
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
追加の対策
package.json の更新
rollup を明示的に devDependencies に追加しました (将来的な安定性のため):
"devDependencies": {
"rollup": "^4.54.0",
...
}
学んだこと
- npm ci は reproducible なインストールを優先するため、optional dependencies の扱いが保守的
- CI 環境では特に問題が発生しやすい
- プラットフォーム固有のネイティブバイナリは optional dependencies として配布される
- CI 環境のプラットフォームと開発環境が異なる場合、特に注意が必要
- 間接的な依存関係 (tsup → rollup) の問題は見つけにくい
- 重要な依存関係は明示的に devDependencies に追加することを検討
参考リンク
package-lock.jsonwhen reinstalling withnode_modulespresent npm/cli#4828 - Optional dependencies bug