create-vinext-app generates `packageManager` without a pnpm version on windows, causing corepack to fail
Description
Creating a project with create-vinext-app on Windows using pnpm and the default options, including the Cloudflare deployment target, fails during dependency installation:
No version specified for pnpm in "packageManager" of package.json
Command failed with exit code 1: pnpm add vinext react-server-dom-webpack @vinext/cloudflareThe scaffolder generates:
{
"packageManager": "pnpm"
}Corepack requires a version in this field, such as [email protected], and rejects the generated value before dependency installation can proceed.
Reproduction
On Windows with a Corepack-managed pnpm installation:
Verify that
pnpm --versionworks in the starting directory.Run:
pnpm create vinext-appAccept the default options, including Cloudflare.
Observe the installation failure.
Inspect the generated
package.json:packageManagercontainspnpmwithout a version.
Expected behavior
Project creation should complete successfully.
The generated packageManager field should include the detected pnpm version. If version detection fails, the scaffolder should handle that failure without writing a value that Corepack rejects.
Suspected cause
In packages/create-vinext-app/src/index.ts, getPackageManagerVersion() invokes:
spawnSync(packageManager, ["--version"], {
encoding: "utf-8",
stdio: ["ignore", "pipe", "ignore"],
});In the Windows installation used for local reproduction, pnpm is exposed through a Corepack pnpm.cmd launcher. Calling spawnSync("pnpm", ["--version"]) directly fails with ENOENT, returning status: null.
Consequently, version detection returns null. writePackageJson() then falls back to the package manager name:
packageManager: version ? `${packageManager}@${version}` : packageManager,This writes "packageManager": "pnpm", which causes the subsequent Corepack invocation to fail.
Source: cloudflare/vinext