Unstable Next 14 Migration: Error: Invariant: Expected to replace at least one import #63078
Replies: 3 comments 1 reply
-
sounds like this issue, did they bother to solve this? or what should I do also found this |
Beta Was this translation helpful? Give feedback.
-
I was running into a similar problem. Check your node version and make sure it's supported. Upgrade if necessary :) |
Beta Was this translation helpful? Give feedback.
-
Try redeploying your branch on Vercel without "Use existing build cache".
|
Beta Was this translation helpful? Give feedback.
-
TLDR; Unable to work with nextjs-14 project locally after migrating to app dir from next-12, keeps running into
Invariant import
exception, however build and deployments works fine. The error is easily reproducible on our local machines. If anyone could share their experience on similar problem or help me decrypt the error message, i will be very grateful!Our team has been in a process of migrating from next-12 to latest next-14 release with app dir (no pages dir) and unfortunately we have hit a wall in the process and are unable to make any progress.
Nextjs keeps throwing
Error: Invariant: Expected to replace at least one import
on catch-all segment routes like[...path]
and we have been unsuccessful in isolating the cause of this problem.The full error message:
difficult to create a reproduction.
The error logs doesn't point to any specific file or full stack trace, either in server console logs and runtime red screen. However, surprisingly, the local build as well as preview deployments work fine.
I am on, "next": "^14.1.0", and in a monorepo project setup with turbo and complete app-dir without
/pages
directory . Unfortunately, i am unable to create a reproduction on a fresh nextjs project. The project is huge and without proper error messages itsI have tried all general workarounds like:
node_modules
from all projectspackage-lock.json
, building from scratch. No noticeable change was found.I attempted to take a deep dive into the code execution through debugger, i managed to trace the exception to a file called
load-entrypoint.js
, it's precisely at this file the program throws the exception.Beta Was this translation helpful? Give feedback.
All reactions