Next.js Discord

Discord Forum

App crashes at runtime with error: Uncaught (in promise) ReferenceError: packageName is not defined

Unanswered
Somali posted this in #help-forum
Open in Discord
SomaliOP
I have upgraded my nextjs app to latest next 15.3.3 and react 19.0.0. While everything works well on local, app builds and runs as expected, in production, app crashes with (difficult to debug error) message:

"Uncaught (in promise) ReferenceError: packageName is not defined"

The stack trace is obfuscated. And as I said above, thinks work on local so I can't really reproduce this issue. Any help would be greatly appreciated.

3 Replies

Hey! Did you ever get a solution on this? I currently having the exact same error on my nextjs app. Were you by any chance using Clerk for authentication?
Northeast Congo Lion
This error usually happens because of how React 19 and Next.js 15 handle server actions, RSC, and bundling in production mode. In development, Next.js uses a different bundler/runtime, so certain references might work locally but fail after minification and tree-shaking in production. I think.
I found the problem. I was using the Clerk's react package (@clerk/clerk-react) for the provider, instead of the Next.js specific package (@clerk/nextjs). Switching to this one solved the issue for me.