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