Skip to content

Commit a41a2ae

Browse files
committed
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.
1 parent 2d77d73 commit a41a2ae

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

ng-dev/release/publish/actions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,13 @@ export abstract class ReleaseAction {
369369
/** Installs all Yarn dependencies in the current branch. */
370370
protected async installDependenciesForCurrentBranch() {
371371
if (await this.pnpmVersioning.isUsingPnpm(this.projectDir)) {
372+
// Note: We delate all contents of `node_modules` before installing dependencies. We do
373+
// this because if a pnpm workspace package exists at one ref and not another, it can
374+
// cause the pnpm install from within Bazel to errantly attempt to install a package that
375+
// does not exist.
376+
try {
377+
this.git.run(['clean', '-qdfX', '**/node_modules']);
378+
} catch {}
372379
await ExternalCommands.invokePnpmInstall(this.projectDir);
373380
return;
374381
}

ng-dev/release/publish/external-commands.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,10 @@ export abstract class ExternalCommands {
223223
'install',
224224
...(yarnCommand.legacy ? ['--frozen-lockfile', '--non-interactive'] : ['--immutable']),
225225
],
226-
{cwd: projectDir},
226+
{
227+
cwd: projectDir,
228+
mode: 'on-error',
229+
},
227230
);
228231
Log.info(green(' ✓ Installed project dependencies.'));
229232
} catch (e) {
@@ -250,6 +253,7 @@ export abstract class ExternalCommands {
250253
],
251254
{
252255
cwd: projectDir,
256+
mode: 'on-error',
253257
},
254258
);
255259

0 commit comments

Comments
 (0)