Error: Invariant: Expected to replace at least one import
Unanswered
Bearded Collie posted this in #help-forum
Bearded CollieOP
./node_modules/next/dist/build/webpack/loaders/next-route-loader/index.js?kind=PAGES&page=%2F_error&preferredRegion=&absolutePagePath=.%2Fnode_modules%2Fnext%2Fdist%2Fpages%2F_error.js&absoluteAppPath=next%2Fdist%2Fpages%2F_app&absoluteDocumentPath=next%2Fdist%2Fpages%2F_document&middlewareConfigBase64=e30%3D!I found myself in strange situation where, I kept running into the above issue, which doesn't point to any specific file or full stack trace, this is shown on both 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", (next-14) and in a monorepo setup with turbo and complete app-dir without /pages directory . Unfortunately, i am unable to create a reproduction on a fresh nextjs project. Using debuger, i managed to trace the exception to a file called
load-entrypoint.js (attached SS) at next/dist/build/load-entrypoint.jsI have attempted all traditional steps like removing node_modules and .next, reinstalling next, even upgradin to latest canary, but no change.
Thank you.