Ref https://github.com/facebook/create-react-app/pull/11322#issuecomment-
906621551
// Supported package managers: pnpm > yarn > npm
// Note: until <https://github.com/pnpm/pnpm/issues/3505> is resolved,
// it is not possible to tell if the command is called by `pnpm init`.
- const packageManagerBinary = path.basename(process.env.npm_execpath || '')
- const packageManager = /pnpm/.test(packageManagerBinary)
- ? 'pnpm'
- : /yarn/.test(packageManagerBinary)
- ? 'yarn'
- : 'npm'
+ const userAgent = process.env.npm_config_user_agent ?? ''
+ const packageManager = /pnpm/.test(userAgent) ? 'pnpm' : /yarn/.test(userAgent) ? 'yarn' : 'npm'
// README generation
fs.writeFileSync(