Let pnpm recreate node_modules during Next.js deploy - #57
Conversation
The install step captures pnpm's output, so pnpm has no TTY. When it needs to recreate node_modules (for example after a different pnpm major version installed it), it can't ask for confirmation and aborts with ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY. Pass --config.confirm-modules-purge=false to pnpm so it purges without asking. npm and yarn are left alone. Co-Authored-By: siGit Code <noreply@sigit.si>
There was a problem hiding this comment.
Modified the Next.js SSR deploy process to add the flag --config.confirm-modules-purge=false when running pnpm install with captured stdio, to avoid the error ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY when pnpm needs to recreate node_modules without a TTY. This prevents deploy failures due to pnpm aborting the removal of the modules directory.
Automated review by siGit Code Review · commit 052e2e8 · see the review dashboard
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: siGit Code <noreply@sigit.si>
There was a problem hiding this comment.
This change fixes the ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY deploy failure by passing --config.confirm-modules-purge=false to pnpm installs in process_deploy_nextjs_ssr, so pnpm can recreate an incompatible node_modules without a TTY prompt. The command builder was restructured into a mut builder to conditionally add the flag, with the install/output handling otherwise unchanged. Both open threads from the earlier review are resolved here: the fragile literal "pnpm" comparison is now a case-insensitive file_stem match that also covers full paths and Windows pnpm.cmd shims, and the requested note on why CI=true was avoided is in the comment (line 223). I verified the time-sensitive claims against public pnpm sources: confirmModulesPurge is a real setting in pnpm 10/11 that skips the purge confirmation, and pnpm does enable --frozen-lockfile by default when CI=true, so the author's reasoning for not using CI=true holds. The kebab-case --config. form was empirically tested by the author against pnpm 10.25.0 and pnpm normalizes kebab-case CLI flags to camelCase settings, so the flag name is fine. No new issues found.
Automated review by siGit Code Review · commit 761660c · see the review dashboard
smb deployfor anextjs-ssrproject failed at the install step with:We capture pnpm's stdout/stderr to keep the spinner clean, so pnpm has no TTY. If
node_moduleswas installed by a different pnpm (here pnpm 11 installed it and pnpm 10 was first on PATH), pnpm wants to wipe and recreate it, can't prompt, and gives up.The fix passes
--config.confirm-modules-purge=falsewhen the package manager is pnpm. I didn't useCI=truebecause that also turns on--frozen-lockfile, which would break deploys with a slightly stale lockfile.Tested by reproducing the error with pnpm 10.25.0 against a pnpm 11
node_modules, then running the same install with the flag on a copy of the project. It purged and reinstalled cleanly. clippy is clean.Release Notes:
smb deployfailing on Next.js projects when pnpm needs to recreatenode_modules.