Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add npm to create-next-app environment package manager parser #41279

Merged
merged 10 commits into from
Oct 13, 2022
14 changes: 7 additions & 7 deletions packages/create-next-app/helpers/get-pkg-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ export type PackageManager = 'npm' | 'pnpm' | 'yarn'
export function getPkgManager(): PackageManager {
try {
const userAgent = process.env.npm_config_user_agent

if (userAgent) {
if (userAgent.startsWith('yarn')) {
execSync('yarn --version', { stdio: 'ignore' })
return 'yarn'
} else if (userAgent.startsWith('pnpm')) {
execSync('pnpm --version', { stdio: 'ignore' })
return 'pnpm'
} else {
return 'npm'
}
}
try {
execSync('yarn --version', { stdio: 'ignore' })
return 'yarn'
} catch {
execSync('pnpm --version', { stdio: 'ignore' })
return 'pnpm'
} else {
return 'npm'
}
} catch {
return 'npm'
Expand Down