From f9cd2e377f4a43da6c22086206d4d3b932926134 Mon Sep 17 00:00:00 2001 From: shashankboosi Date: Fri, 11 Oct 2024 03:57:42 +1100 Subject: [PATCH 1/2] Log a detailed error on the console and exist the process if we cannot find the next config file --- packages/cloudflare/src/cli/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cloudflare/src/cli/index.ts b/packages/cloudflare/src/cli/index.ts index 24ee2bf..29d273d 100644 --- a/packages/cloudflare/src/cli/index.ts +++ b/packages/cloudflare/src/cli/index.ts @@ -10,7 +10,10 @@ console.log(`Building the Next.js app in the current folder (${nextAppDir})`); if (!["js", "cjs", "mjs", "ts"].some((ext) => existsSync(`./next.config.${ext}`))) { // TODO: we can add more validation later - throw new Error("Error: Not in a Next.js app project"); + console.error( + "Error: next.config file not found. Please make sure you run the command inside a Next.js app" + ); + process.exit(1); } const { skipBuild, outputDir } = getArgs(); From 3f8d4636b3750649b9c63bd14b9276219761a325 Mon Sep 17 00:00:00 2001 From: shashankboosi Date: Fri, 11 Oct 2024 04:03:09 +1100 Subject: [PATCH 2/2] Add the patch changeset for the PR --- .changeset/swift-geckos-turn.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .changeset/swift-geckos-turn.md diff --git a/.changeset/swift-geckos-turn.md b/.changeset/swift-geckos-turn.md new file mode 100644 index 0000000..2b9ba56 --- /dev/null +++ b/.changeset/swift-geckos-turn.md @@ -0,0 +1,9 @@ +--- +"@opennextjs/cloudflare": patch +--- + +enhancement: Expand missing next.config error message + +Found out that next dev can run the a Next.js app without next.config but +if we are using the adapter we throw an error if we don't find the config. +So expanded the error for users.