From 61d0a2f0441038423b824ae2f3151dcb9dad3bb0 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Tue, 28 Nov 2023 22:27:43 +0000 Subject: [PATCH] print warning in case developers are using a different package manager to run @cloudflare/next-on-pages (#554) --- .changeset/blue-seals-fail.md | 5 +++++ .../src/buildApplication/buildApplication.ts | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .changeset/blue-seals-fail.md diff --git a/.changeset/blue-seals-fail.md b/.changeset/blue-seals-fail.md new file mode 100644 index 000000000..9616927c0 --- /dev/null +++ b/.changeset/blue-seals-fail.md @@ -0,0 +1,5 @@ +--- +'@cloudflare/next-on-pages': patch +--- + +print warning in case developers are using a different package manager to run @cloudflare/next-on-pages diff --git a/packages/next-on-pages/src/buildApplication/buildApplication.ts b/packages/next-on-pages/src/buildApplication/buildApplication.ts index 0e18c5f78..ee7881044 100644 --- a/packages/next-on-pages/src/buildApplication/buildApplication.ts +++ b/packages/next-on-pages/src/buildApplication/buildApplication.ts @@ -3,7 +3,7 @@ import { join, resolve } from 'path'; import { cp } from 'fs/promises'; import { getPackageManager } from 'package-manager-manager'; import type { CliOptions } from '../cli'; -import { cliError, cliLog, cliSuccess } from '../cli'; +import { cliError, cliLog, cliSuccess, cliWarn } from '../cli'; import { getVercelConfig } from './getVercelConfig'; import { buildWorkerFile } from './buildWorkerFile'; import { buildVercelOutput } from './buildVercelOutput'; @@ -43,6 +43,15 @@ export async function buildApplication({ throw new Error('Error: Could not detect current package manager in use'); } + if (pm.projectPackageManager && pm.name !== pm.projectPackageManager) { + cliWarn( + `The project is set up for ${pm.projectPackageManager} but it is currently being run` + + ` via ${pm.name} this might lead to build errors, please be sure to use the same package manager` + + ` your project uses when running @cloudflare/next-on-pages`, + { spaced: true }, + ); + } + let buildSuccess = true; if (!skipBuild) { try {