diff --git a/packages/next/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts b/packages/next/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts index 53fd151649f8..c95bc508e748 100644 --- a/packages/next/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts +++ b/packages/next/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts @@ -114,9 +114,9 @@ export async function getNotFoundError( importTrace() + '\nhttps://nextjs.org/docs/messages/module-not-found' - if (await isEdgeRuntimeCompiled(compilation, input.module, config)) { - const moduleName = getUnresolvedModuleFromError(input.message) - if (moduleName) { + const moduleName = getUnresolvedModuleFromError(input.message) + if (moduleName) { + if (await isEdgeRuntimeCompiled(compilation, input.module, config)) { message += '\n\n' + getNodeBuiltinModuleNotSupportedInEdgeRuntimeMessage(moduleName)