From 56e16c39962a1879ba87b576d8063907ca62e682 Mon Sep 17 00:00:00 2001 From: Sergey Bahmatov Date: Mon, 5 Oct 2026 14:12:05 +0500 Subject: [PATCH] fix: clean Yarn 4.x PnP files before yarn install PnP files (.pnp.cjs, .pnp.d.ts, .pnp.loader.mjs) can cause stale typescript patch resolution errors (ENOENT _tsc.js). Clean them before yarn install and before retry. --- npm_install.py | 10 ++++++++++ npm_install_multiversion.py | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/npm_install.py b/npm_install.py index 705f177..36ecb30 100644 --- a/npm_install.py +++ b/npm_install.py @@ -2312,6 +2312,12 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path): os.chdir(src_frontend) _prepare_sass(src_frontend) + # Clean Yarn 4.x PnP files that can cause stale patch resolution + for pnp_file in [".pnp.cjs", ".pnp.d.ts", ".pnp.loader.mjs"]: + p = src_frontend / pnp_file + if p.exists(): + p.unlink() + shutil.rmtree(src_frontend / ".yarn", ignore_errors=True) shutil.rmtree(src_frontend / "node_modules", ignore_errors=True) run(yarn_cmd + ["cache", "clean", "--all"], check=False) @@ -2344,6 +2350,10 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path): node_modules = src_frontend / "node_modules" if node_modules.exists(): shutil.rmtree(node_modules, ignore_errors=True) + for pnp_file in [".pnp.cjs", ".pnp.d.ts", ".pnp.loader.mjs"]: + p = src_frontend / pnp_file + if p.exists(): + p.unlink() run(install_cmd, timeout=1200) except Exception as e: diff --git a/npm_install_multiversion.py b/npm_install_multiversion.py index cbd71ac..35e67ae 100644 --- a/npm_install_multiversion.py +++ b/npm_install_multiversion.py @@ -2034,6 +2034,12 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path): except Exception: pass + # Clean Yarn 4.x PnP files that can cause stale patch resolution + for pnp_file in [".pnp.cjs", ".pnp.d.ts", ".pnp.loader.mjs"]: + p = src_frontend / pnp_file + if p.exists(): + p.unlink() + # Clean cache try: run(yarn_cmd + ["cache", "clean"], check=False)