Next.js Build Error with Ably + serverComponentsExternalPackages
Unanswered
Asian black bear posted this in #help-forum
Asian black bearOP
Build fails with "Element type is invalid" error when using
Details:
- Next.js 14.2.29 App Router
- Works fine in dev (
- Fails during build (
- Even with ALL Ably code commented out, just having the config breaks the build
Config:
Error:
Error occurred prerendering pages.
Element type is invalid: expected a string (for built-in components)
or a class/function (for composite components) but got: undefined.
serverComponentsExternalPackages: ["ably"]
in next.config.jsDetails:
- Next.js 14.2.29 App Router
- Works fine in dev (
npm run dev
) - Fails during build (
npm run build
) with prerender errors- Even with ALL Ably code commented out, just having the config breaks the build
Config:
// next.config.js
experimental: {
serverComponentsExternalPackages: ["ably"]
}
Error:
Error occurred prerendering pages.
Element type is invalid: expected a string (for built-in components)
or a class/function (for composite components) but got: undefined.
2 Replies
ably components should be dynamic imported
@chisto ably components should be dynamic imported
Asian black bearOP
I've done all that, with ssr false and all the best practices, that's why I mentioned everything is working well in dev mode with no warnings no errors but in build it brakes with this error