fix: CI failing on @rollup/rollup-linux-x64-gnu missing optional dep#1
Conversation
- Remove `cache: npm` from actions/setup-node (primary fix — stale npm cache can cause platform-specific optional deps like @rollup/rollup-linux-x64-gnu to be skipped, per npm/cli#4828) - Add defensive verification step after npm ci: if the Rollup Linux native binary is still missing, wipe node_modules and reinstall from scratch, emitting a workflow warning Fixes: https://github.com/DynamoDS/DynoDashGame/actions/runs/25089724982 Agent-Logs-Url: https://github.com/DynamoDS/DynoDashGame/sessions/dbdb61eb-cb25-4573-8708-a764c86078ad Co-authored-by: QilongTang <3942418+QilongTang@users.noreply.github.com>
|
@copilot The PR check is failing, fix it as part of this same PR |
The CI workflow (ci.yml) used by pull_request checks had the same `cache: npm` / missing @rollup/rollup-linux-x64-gnu issue as deploy.yml. Apply identical fixes: remove `cache: npm` and add defensive reinstall guard. Agent-Logs-Url: https://github.com/DynamoDS/DynoDashGame/sessions/ccd45fb5-a1c2-4023-b9bd-907559539f05 Co-authored-by: QilongTang <3942418+QilongTang@users.noreply.github.com>
The CI failure was in a separate |
|
@copilot The CI check is still failing, try again |
…aries Root cause: package-lock.json was committed from macOS (only had @rollup/rollup-darwin-arm64). npm ci strictly follows the lock file, so @rollup/rollup-linux-x64-gnu was never installed on CI, causing the Vitest startup error even after the node_modules wipe-and-reinstall fallback (which also uses npm ci against the same stale lock file). Fix: regenerated package-lock.json from scratch on Linux after clearing the npm cache. The new lock file records all platform-specific rollup binaries (linux, darwin, win32, etc.) as optional:true, so npm ci on any platform will correctly install the matching native binary. Agent-Logs-Url: https://github.com/DynamoDS/DynoDashGame/sessions/53263425-3d0c-4547-90b3-0557b45f1fd9 Co-authored-by: QilongTang <3942418+QilongTang@users.noreply.github.com>
Found the real root cause: Fixed in commit |
npm cisilently skips platform-specific optional dependencies when the lock file was generated on a different OS (npm/cli#4828), causing Vitest/Rollup to throwCannot find module @rollup/rollup-linux-x64-gnuat startup. Failing run: #25089724982.Root Cause
package-lock.jsonwas committed from macOS and only recorded@rollup/rollup-darwin-arm64. Sincenpm cistrictly follows the lock file,@rollup/rollup-linux-x64-gnuwas never installed on the Linux CI runner — even a node_modules wipe-and-reinstall fallback failed because it also rannpm ciagainst the same stale lock file.Changes
Regenerate
package-lock.json— primary fix. Deleted the stale macOS-generated lock file and regenerated it from scratch on Linux (npm cache clean --force+npm install). The new lock file records all platform-specific rollup binaries (linux,darwin,win32, etc.) asoptional: true, sonpm cion any platform installs the correct native binary.Remove
cache: npmfromactions/setup-nodein bothci.ymlanddeploy.yml— belt-and-suspenders fix. Prevents a warm npm cache from poisoning optional-dep resolution.Add defensive post-install guard in both workflows — probes the native binary after
npm ci; if still absent, wipesnode_modulesand reinstalls from scratch before tests run. Emits a workflow warning so the fallback is visible in logs.Original prompt
Create a pull request in
DynamoDS/DynoDashGameto fix the GitHub Actions workflow failing in CI.Context:
.github/workflows/deploy.ymlError: Cannot find module @rollup/rollup-linux-x64-gnuduringnpm test(Vitest startup / Rollup native module).actions/setup-node@v4withnode-version: 20andcache: npm, then runsnpm ci,npm test,npm run build, and uploadsdist.Goal:
Requirements:
actions/setup-nodenpm caching if it is the likely root cause.@rollup/rollup-linux-x64-gnucan be required; if missing, perform a clean reinstall (e.g., removenode_modulesand rerunnpm ci, avoiding deletingpackage-lock.jsonunless necessary).dist.Deliverables:
.github/workflows/deploy.ymlaccordingly.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Why did this job fail?
Assistant: The job failed during the test step when
vitest runtried to start up, because Rollup’s Linux native binary package wasn’t present innode_modules.From the job log (run
25089724982, job73513077056):> vitest runError: Cannot find module @rollup/rollup-linux-x64-gnunode_modules/rollup/dist/native.js1.This is a known npm/optional-dependencies issue (the log even references
https://github.com/npm/cli/issues/4828): the platform-specific optional dependency for Rollup sometimes doesn’t get installed correctly in CI, so Vitest/Vite/Rollup can’t load the native module and aborts.Link to the failing job log (same ref as the run):
https://github.com/DynamoDS/DynoDashGame/actions/runs/25089724982/job/73513077056#step:5:42
If you want, paste your
.github/workflows/deploy.ymlinstall steps (npm ci vs npm i, caching, Node version), and I can suggest the most reliable fix for this workflow.User: ```
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
If you want to keep caching anyway
Add a defensive reinstall specifically when the Rollup native module is missing (keeps the workflow resilient):
(You could also replace
npm iwithnpm ciafter regenerating the lock, but typically you don’t want to delete the lock in CI unless you accept lockfile changes.)Also check: are you on npm 10.x?
Node 20 on GitHub-hosted runners typically uses npm 10+, and this class of issue tends to show up there. If you want an additional mitigation, you can pin npm to a known-good version in the workflow:
Quick recommendation
Start with the simplest: remove
cache: npm, re-run the...This pull request was created from Copilot chat.