npm reads workspace package.json when run from source directory.
The frontend package.json contains patch: entries (Yarn 4.x PnP)
that npm can't understand. Run from /tmp instead.
Also fix 'run() got an unexpected keyword argument stdout' by
using subprocess.run() directly for npm uninstall/cache clean.
yarn@berry and yarn@latest install yarn 1.x, not yarn 4.x.
@yarnpkg/cli is the actual yarn 4.x npm package. Also restore
yarn 1.x before 'yarn set version stable' on METHOD 4.
Global /root/.yarn cache contains stale builtin<compat/typescript>
patch references to _tsc.js that don't exist in typescript 7.0.2.
Clean it before each yarn install attempt.
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.