The build was failing with ReferenceError: document is not defined errors during the "Collecting page data" phase when using Node.js 22. This was caused by lottie-web (a dependency of lottie-react) trying to access browser APIs during server-side rendering.
Root Cause:
Node.js 22 introduced stricter SSR validation compared to Node.js 20
The lottie-web library attempts to access the document object during module initialization
Node.js 22 now catches and throws errors for browser API usage during SSR, while Node.js 20 was more permissive
This affected all pages using Lottie animations (/wallets, /mining, /what-is-ecash, etc.)
Solution:
Implemented dynamic imports in the AnimateImage component to ensure lottie-react only loads on the client side: