Skip to content

Commit 804d31c

Browse files
committed
Use isolated pnpm install for nested packages to prevent JSON corruption
Running pnpm install with hoisted mode in nested directories causes package.json corruption. Use isolated mode (default pnpm behavior without hoisting flags) for the nested install to avoid conflicts.
1 parent 28416bc commit 804d31c

1 file changed

Lines changed: 22 additions & 8 deletions

File tree

scripts/install-npm-packages.mjs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,19 @@ async function installPackage(packageInfo) {
451451

452452
// Explicitly install dependencies in the nested package to ensure test
453453
// runners (tape, mocha, ava, etc.) are available.
454-
await runCommand('pnpm', ['install', ...PNPM_INSTALL_FLAGS], {
455-
cwd: installedPath,
456-
env: { ...process.env, ...PNPM_INSTALL_ENV },
457-
})
454+
// Use isolated mode (not hoisted) to avoid conflicts with parent installation.
455+
await runCommand(
456+
'pnpm',
457+
[
458+
'install',
459+
'--config.confirmModulesPurge=false',
460+
'--no-frozen-lockfile',
461+
],
462+
{
463+
cwd: installedPath,
464+
env: { ...process.env, ...PNPM_INSTALL_ENV },
465+
},
466+
)
458467

459468
// Apply Socket overrides to all nested dependencies recursively.
460469
await applyNestedSocketOverrides(installedPath)
@@ -739,10 +748,15 @@ async function installPackage(packageInfo) {
739748

740749
// Explicitly install dependencies in the nested package to ensure test
741750
// runners (tape, mocha, ava, etc.) are available.
742-
await runCommand('pnpm', ['install', ...PNPM_INSTALL_FLAGS], {
743-
cwd: installedPath,
744-
env: { ...process.env, ...PNPM_INSTALL_ENV },
745-
})
751+
// Use isolated mode (not hoisted) to avoid conflicts with parent installation.
752+
await runCommand(
753+
'pnpm',
754+
['install', '--config.confirmModulesPurge=false', '--no-frozen-lockfile'],
755+
{
756+
cwd: installedPath,
757+
env: { ...process.env, ...PNPM_INSTALL_ENV },
758+
},
759+
)
746760

747761
// Apply Socket overrides to all nested dependencies recursively.
748762
await applyNestedSocketOverrides(installedPath)

0 commit comments

Comments
 (0)