diff --git a/create-turbo/src/index.ts b/create-turbo/src/index.ts index 8c770ed55756d..1be2735a74e47 100644 --- a/create-turbo/src/index.ts +++ b/create-turbo/src/index.ts @@ -11,7 +11,7 @@ import checkForUpdate from "update-check"; import chalk from "chalk"; import cliPkgJson from "../package.json"; import { shouldUseYarn } from "./shouldUseYarn"; -import { shouldUsePnpm } from "./shouldUsePnpm"; +import { shouldUsePnpm, getNpxCommandOfPnpm } from "./shouldUsePnpm"; import { tryGitInit } from "./git"; type PackageManager = "yarn" | "pnpm" | "npm"; @@ -310,7 +310,7 @@ function getNpxCommand(pkgManager: PackageManager): string { if (pkgManager === "yarn") { return "npx"; } else if (pkgManager === "pnpm") { - return "pnpx"; + return getNpxCommandOfPnpm(); } else { return "npx"; } diff --git a/create-turbo/src/shouldUsePnpm.ts b/create-turbo/src/shouldUsePnpm.ts index 9350f82ba9f78..ad2ed8b26c7e0 100644 --- a/create-turbo/src/shouldUsePnpm.ts +++ b/create-turbo/src/shouldUsePnpm.ts @@ -12,3 +12,8 @@ export function shouldUsePnpm(): boolean { return false; } } + +export function getNpxCommandOfPnpm() { + const currentVersion = execSync("pnpm --version").toString(); + return Number(currentVersion.split(".")[0]) >= 6 ? "pnpm dlx" : "pnpx"; +}