Deploy Static Site Using Yarn 4 Berry

I’m trying to deploy a static site built with vite + reactjs using yarn 4 berry. When I do, I get the errors below. I have a .nvmrc that installs Node 22.

I found a post on “community” at /t/deploy-on-render-with-yarn-v4/24731(Render won’t let me post if there’s a link to their own site for some reason), and altered my build command to corepack enable && yarn install && yarn build but the errors are the same.

How do I properly configure my settings in Render to stop using the global Yarn 1 that Render has and instead use Yarn 4?

2025-06-03T18:43:17.614756575Z ==> Cloning from https://github.com/foo/bar
2025-06-03T18:43:18.431161152Z ==> Checking out commit badc0ffee0ddf00dbabe1234567890abcdeffedcb in branch main
2025-06-03T18:43:20.662530201Z ==> Installing dependencies with Yarn...
2025-06-03T18:43:20.763223725Z ==> Requesting Node.js version v22
2025-06-03T18:43:21.32889266Z ==> Using Node.js version 22.16.0 via /opt/render/project/src/.nvmrc
2025-06-03T18:43:21.377357889Z ==> Docs on specifying a Node.js version: https://render.com/docs/node-version
2025-06-03T18:43:23.994184358Z ==> Using Bun version 1.1.0 (default)
2025-06-03T18:43:23.994204208Z ==> Docs on specifying a bun version: https://render.com/docs/bun-version
2025-06-03T18:43:24.47548643Z error This project's package.json defines "packageManager": "yarn@4.9.1". However the current global version of Yarn is 1.22.22.
2025-06-03T18:43:24.475683593Z 
2025-06-03T18:43:24.475731644Z Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
2025-06-03T18:43:24.475761034Z Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.

I ended up doing a custom build.sh script. My root repo has a package.json like this:

{
  "name": "foo",
  "private": true,
  "workspaces": ["app"],
  "devDependencies": {"typescript": "^5.1.6"},
  "packageManager": "yarn@4.9.2"
}

And I have a main app sub-folder that houses the SPA. I added a build.sh file to the root that looks like this:

#!/usr/bin/env bash

set -o errexit
set -o nounset

corepack enable

corepack prepare yarn@4.9.2 --activate

yarn install --immutable

yarn workspace app build

and set an env var under MANAGE > Environment to SKIP_INSTALL_DEPS=true and set Settings > Publish Directory to app/dist. The next deploy worked.

… I also have my Settings > Build Command set to this:

npm install -g corepack && corepack enable && yarn set version 4.9.2 && yarn install && cd app && yarn build