Hi everyone,
We’re running into a stubborn build error while trying to deploy our Next.js application to Firebase App Hosting, and we’re hoping the community might have some insights or suggestions.
Our Tech Stack:
- Frontend: Next.js (version 15.2.3, as reported by the build)
- Deployment: Firebase App Hosting
- Development Environment: Project IDX
The Problem:
Our build consistently fails with a syntax error in a specific file, src/app/weer-dashboard/page.tsx
. The error message is always:
Error: Expected ‘from’, got ‘g’ ,-[/home/user/studio/src/app/weer-dashboard/page.tsx:34:1] … (and the import trace) … Caused by: Syntax Error
This error points to a malformed import statement, specifically on line 34. However, even when we drastically simplify the content of this file, the error persists on what appears to be the same line number, suggesting the build process might not be correctly reflecting the actual file content or there’s a deeper issue with file interpretation.
Additionally, we’ve seen a “Could not find the module” error that seemed related to a nested workspace/workspace
directory in the build path, which we’ve since addressed.
What We Have Tried:
- Initial Syntax Error Correction: We identified an initial syntax error (a missing closing curly brace) in a different file (
src/actions/rampen.ts
) and corrected it. - Metadata Export Fix: We commented out a
metadata
export in a client component (src/app/premium/success/page.tsx
) as it’s not allowed in Next.js. - Refactoring with Suspense: We attempted to move the logic from
src/app/weer-dashboard/page.tsx
to a separate client component (src/components/weer-dashboard.tsx
) and wrap it with<Suspense>
to address potential server-side rendering issues with hooks likeuseSearchParams()
. This attempt was hampered by issues with file writing/syncing in the environment. - Adding
export const dynamic = 'force-dynamic';
: We addedexport const dynamic = 'force-dynamic';
to the top ofsrc/app/weer-dashboard/page.tsx
to force dynamic rendering and prevent pre-rendering issues. - Reverting Commits: We attempted to revert commits to return to a previous state, but this reintroduced earlier errors.
- Deleting Nested Directory: We identified and deleted a nested
workspace/workspace
directory that appeared to be confusing the build process regarding the project root. - Clearing Cache and Reinstalling Dependencies: We deleted the local
.next
cache and rannpm install
to ensure a clean build environment. - Simplifying
weer-dashboard/page.tsx
: As a test, we replaced the entire content ofsrc/app/weer-dashboard/page.tsx
with minimal, correct code, but the same syntax error persists on what the build reports as line 34.
What Did Not Succeed:
Despite multiple attempts and various fixes, the build continues to fail with the same “Expected ‘from’, got ‘g’” syntax error in src/app/weer-dashboard/page.tsx
. It seems the build process is not consistently reflecting the changes made to this file, or there’s an underlying issue with how the build environment interprets it.
What We Are Looking For From the Community:
- Similar Experiences: Has anyone encountered a similar persistent syntax error during the build process with Next.js on Firebase App Hosting, especially one that seems unrelated to the actual file content?
- Insights into Build Process: Any insights into the build process of Next.js on Firebase App Hosting, particularly regarding file synchronization, caching, or how the project root is determined, would be invaluable.
- Troubleshooting Suggestions: Are there any other troubleshooting steps we could try from within the IDE or related to Firebase Hosting configuration that might address this kind of file synchronization/interpretation issue?
- Workarounds: Any potential workarounds that could help us bypass this specific file’s build problem?
We are quite stuck on this and appreciate any help or guidance the community can provide.
Thanks in advance for your time and expertise!