diff --git a/npm_install.py b/npm_install.py index 06e879f..6006cb1 100644 --- a/npm_install.py +++ b/npm_install.py @@ -2173,6 +2173,9 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path): # METHOD 1: Corepack (recommended for Yarn 4.x) if shutil.which("corepack"): try: + # Uninstall old yarn 1.x to prevent conflicts + subprocess.run(["npm", "uninstall", "-g", "yarn"], check=False, cwd="/tmp") + # Enable corepack subprocess.run( ["corepack", "enable"], @@ -2201,13 +2204,13 @@ def _build_frontend(src_frontend: Path, dest_frontend: Path): # Check version if shutil.which("yarn"): - major = _get_yarn_major_version(["yarn"]) - - if major and major >= 4: - if DEBUG: - print(f" ✓ Yarn {major}.x installed via corepack") - os.chdir(original_cwd) - return True + major = _get_yarn_major_version(["yarn"]) + + if major and major >= 4: + if DEBUG: + print(f" ✓ Yarn {major}.x installed via corepack") + os.chdir(original_cwd) + return True except Exception as e: if DEBUG: print(f" ⚠ Corepack method failed: {e}")