Skip to content

Stop pnpm install from failing when it wants to recreate node_modules without a terminal - #411

Merged
akramhussein merged 1 commit into
mainfrom
akram/pnpm-no-purge-prompt
Nov 5, 2026
Merged

akramhussein merged 1 commit into
mainfrom
akram/pnpm-no-purge-prompt

Conversation

@akramhussein

Copy link
Copy Markdown
Contributor

Why

When UPM runs pnpm install in an automated context, such as a Replit deployment build, pnpm has no terminal to talk to. If pnpm decides the existing node_modules has to be recreated (its store path, layout version or hoisting settings no longer match), it tries to ask "remove node_modules?" first. With no terminal it cannot ask, so it aborts with ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY and the install fails.

UPM always starts pnpm without a stdin, so this prompt can never be answered through UPM. The only thing a user could do was put confirmModulesPurge: false in their own pnpm-workspace.yaml.

What changed

pnpm install (used by both upm lock and upm install for the pnpm backend) now passes --config.confirm-modules-purge=false. That answers the prompt up front, which is the same answer pnpm assumes when it detects CI. It changes nothing else: lockfile handling, frozen installs and so on are untouched, which is why this is preferred over setting CI=true.

The flag is accepted by pnpm 8, 9, 10 and 11 (checked against 8.15.9, 9.15.9, 10.26.1 and 11.9.0).

Test plan

Reproduced the failure with a small project installed by pnpm 10.26.1, then edited node_modules/.modules.yaml to point storeDir at a different path so pnpm wants to recreate node_modules. Ran UPM with stdin redirected from /dev/null:

  • Before: upm -l nodejs-pnpm install --force </dev/null exits 16 with ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY.
  • After: same command exits 0, pnpm recreates node_modules and reports Packages: +11.

Also ran go vet ./internal/backends/nodejs/ and gofmt -l (clean).

~ written by ⠕ Replit

UPM runs pnpm without a stdin, so when pnpm decides node_modules has to be
recreated it cannot ask for confirmation and aborts with
ERR_PNPM_ABORTED_REMOVE_MODULES_DIR_NO_TTY. Pass
--config.confirm-modules-purge=false so pnpm proceeds, as it already does in CI.

Assisted-by: Replit
@akramhussein
akramhussein requested a review from joe-thom November 5, 2026 17:53
@akramhussein akramhussein self-assigned this Nov 5, 2026
@akramhussein
akramhussein marked this pull request as ready for review November 5, 2026 18:35
@akramhussein
akramhussein requested a review from a team as a code owner November 5, 2026 18:35
@akramhussein
akramhussein requested review from darshkpatel and removed request for a team November 5, 2026 18:35
@akramhussein
akramhussein merged commit 0aedfa5 into main Nov 5, 2026
9 checks passed
@akramhussein
akramhussein deleted the akram/pnpm-no-purge-prompt branch November 5, 2026 19:02
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.

2 participants