@nestjs/cli
Version:
The Nest CLI: create NestJS applications, generate modules, controllers and CRUD resources, and build, run and watch projects and monorepos.
15 lines (14 loc) • 541 B
JavaScript
import { PackageManager } from '../package-managers/package-manager.js';
/**
* The package manager that started this process, or npm when none did.
*
* `npx`, `pnpm dlx`, `yarn dlx` and `bunx` all say who they are in
* `npm_config_user_agent` (for example `pnpm/10.4.0 npm/? node/v24.0.0`).
*/
export function detectPackageManager() {
const name = process.env.npm_config_user_agent?.split('/')[0];
const managers = Object.values(PackageManager);
return managers.includes(name)
? name
: PackageManager.NPM;
}