From 09174df6cfbe697ea13e75468b9cd3c6ec7ad01c Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Thu, 17 Aug 2023 12:17:28 -0700 Subject: [PATCH] [remix] Only add workspace check flag for Yarn v1 (#10364) Yarn v2/v3 do not require this flag. --- .changeset/stupid-pumpkins-crash.md | 5 +++++ packages/remix/src/utils.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 .changeset/stupid-pumpkins-crash.md diff --git a/.changeset/stupid-pumpkins-crash.md b/.changeset/stupid-pumpkins-crash.md new file mode 100644 index 000000000..f65bc56ae --- /dev/null +++ b/.changeset/stupid-pumpkins-crash.md @@ -0,0 +1,5 @@ +--- +'@vercel/remix-builder': patch +--- + +Only add workspace check flag for Yarn v1 diff --git a/packages/remix/src/utils.ts b/packages/remix/src/utils.ts index f8ac5db13..c13978be7 100644 --- a/packages/remix/src/utils.ts +++ b/packages/remix/src/utils.ts @@ -1,4 +1,5 @@ import semver from 'semver'; +import { execSync } from 'child_process'; import { existsSync, promises as fs } from 'fs'; import { basename, dirname, join, relative, resolve, sep } from 'path'; import { pathToRegexp, Key } from 'path-to-regexp'; @@ -283,10 +284,16 @@ export function addDependencies( } } else { // 'yarn' - args.push('add', '--ignore-workspace-root-check'); + args.push('add'); if (opts.saveDev) { args.push('--dev'); } + const yarnVersion = execSync('yarn -v', { encoding: 'utf8' }).trim(); + const isYarnV1 = semver.satisfies(yarnVersion, '1'); + if (isYarnV1) { + // Ignoring workspace check is only needed on Yarn v1 + args.push('--ignore-workspace-root-check'); + } } // Don't fail if pnpm is being run at the workspace root