From 67d6e1ce59b7581e8e394338d69b674baea2ac10 Mon Sep 17 00:00:00 2001 From: Larry Williamson Date: Wed, 1 Nov 2023 20:26:23 -0400 Subject: [PATCH] refactor(upgrade): improve error message when package manager cannot be detected (#270) --- src/commands/upgrade.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commands/upgrade.ts b/src/commands/upgrade.ts index 85cfec6b..7a11c677 100644 --- a/src/commands/upgrade.ts +++ b/src/commands/upgrade.ts @@ -45,7 +45,9 @@ export default defineCommand({ // Check package manager const packageManager = getPackageManager(cwd) if (!packageManager) { - console.error('Cannot detect Package Manager in', cwd) + consola.error( + `Unable to determine the package manager used by this project.\n\nNo lock files found in \`${cwd}\`, and no \`packageManager\` field specified in \`package.json\`.\n\nPlease either add the \`packageManager\` field to \`package.json\` or execute the installation command for your package manager. For example, you can use \`pnpm i\`, \`npm i\`, \`bun i\`, or \`yarn i\`, and then try again.`, + ) process.exit(1) } const packageManagerVersion = execSync(`${packageManager} --version`)