From 855106023aeb899108d95b065e9fc85dc012dca9 Mon Sep 17 00:00:00 2001 From: Joey Perrott Date: Thu, 30 Oct 2025 16:42:59 +0000 Subject: [PATCH] fix(ng-dev/release): delete node_modules before pnpm install We delete the node_modules prior to a pnpm install during the release because if a package exists on main, but does not exist on the released branch, the node_modules directory will persist and bazel will attempt to pick it up and install it but no package.json exists for it. --- ng-dev/release/publish/actions.ts | 7 +++++++ ng-dev/release/publish/external-commands.ts | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ng-dev/release/publish/actions.ts b/ng-dev/release/publish/actions.ts index c16a60e33..31cacda08 100644 --- a/ng-dev/release/publish/actions.ts +++ b/ng-dev/release/publish/actions.ts @@ -369,6 +369,13 @@ export abstract class ReleaseAction { /** Installs all Yarn dependencies in the current branch. */ protected async installDependenciesForCurrentBranch() { if (await this.pnpmVersioning.isUsingPnpm(this.projectDir)) { + // Note: We delate all contents of `node_modules` before installing dependencies. We do + // this because if a pnpm workspace package exists at one ref and not another, it can + // cause the pnpm install from within Bazel to errantly attempt to install a package that + // does not exist. + try { + this.git.run(['clean', '-qdfX', '**/node_modules']); + } catch {} await ExternalCommands.invokePnpmInstall(this.projectDir); return; } diff --git a/ng-dev/release/publish/external-commands.ts b/ng-dev/release/publish/external-commands.ts index 3e739e8dc..e618ecc7f 100644 --- a/ng-dev/release/publish/external-commands.ts +++ b/ng-dev/release/publish/external-commands.ts @@ -223,7 +223,10 @@ export abstract class ExternalCommands { 'install', ...(yarnCommand.legacy ? ['--frozen-lockfile', '--non-interactive'] : ['--immutable']), ], - {cwd: projectDir}, + { + cwd: projectDir, + mode: 'on-error', + }, ); Log.info(green(' ✓ Installed project dependencies.')); } catch (e) { @@ -250,6 +253,7 @@ export abstract class ExternalCommands { ], { cwd: projectDir, + mode: 'on-error', }, );