Skip to content

Commit

Permalink
fix(cli): better support for yarn 2+ (#2684 by @frankcalise and @morg…
Browse files Browse the repository at this point in the history
…anick)

[skip ci]
  • Loading branch information
frankcalise committed May 29, 2024
1 parent 7544fac commit e38a02c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/commands/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,18 @@ module.exports = {
const npmrcPath = path(targetPath, ".npmrc")
const npmrcContents = read(npmrcPath)
write(npmrcPath, `${npmrcContents}${EOL}node-linker=hoisted${EOL}`)
} else if (packagerName === "yarn") {
const yarnVersion = await packager.run("-v", { packagerName })
const yarnMajorVersion = parseInt(yarnVersion.split(".")[0], 10)

// if yarn version > 1 fix .yarnrc.yml
if (yarnMajorVersion > 1) {
log(`yarn v${yarnMajorVersion} found... fixing .yarnrc.yml...`)
// append `nodeLinker: node-modules` to .yarnrc.yml
const yarnrcPath = path(targetPath, ".yarnrc.yml")
const yarnrcContents = read(yarnrcPath)
write(yarnrcPath, `${yarnrcContents ?? ""}${EOL}nodeLinker: node-modules${EOL}`)
}
}

// check if there is a dependency cache using a hash of the package.json
Expand Down

0 comments on commit e38a02c

Please sign in to comment.