I’ve specified my package manager as "packageManager": "[email protected]" in package.json and have set the NODE_VERSION and YARN_VERSION env variables (“16.15.1” and “3.2.1”, respectively) and Cloudflare still defaults to npm install instead of yarn. Yarn is available and works correctly in subsequent steps such as yarn build if I disable workspaces to get through the npm stage, but the build ultimately fails to find the files needed since the “workspace:*” links are essential for sharing internal packages.
Everything builds and compiles locally with my existing yarn setup, so there is likely a configuration step I’m missing or is incorrectly implemented, so any suggestions would be greatly appreciated.
@KianNH I do have yarn.lock committed, and coincidentally, your comment triggered something important that I didn’t know about Cloudflare’s deployments. Apparently, the presence of a yarn.lock file in is the implicit trigger to use yarn instead of NPM. I updated the root (leave it at the root of the project) and build output folder (prepend the /app/** path) variables, and everything now works as expected.
For future searchers in case it’s helpful. Locally, yarn is smart enough to trigger a root-level yarn install if executed from within a workspace subdirectory, and maintains a yarn.lock at the root of the project. In the Cloudflare build environment, setting the deployment root to something like /apps/... will default to NPM due to the lack of a yarn.lock within the sub folder.
internally yarn build navigates to the right workspace and does build there like yarn workspace @foobar/react build
now Cloudflare will see root directory of / and find yarn.lock there, so it will install packages by doing yarn install. this will be visible in the build logs. after that it will run the provided build command, which will do the react build. and finally Cloudflare will know where to get the output files to run the site from as they will be in the provided build output directory.