Build Error in Next.js 14 with nuqs 1.17.1 - 'cache' Not Exported from 'react' #530
-
Hello, I am encountering an issue when trying to build my project using Next.js 14 with nuqs version 1.17.1. During the build process with the Failed to compile. ./node_modules/nuqs/dist/chunk-6GIZOTLC.js This error suggests that the nuqs package is trying to import This occurs during the build phase and is preventing successful compilation. Here is a brief overview of my environment:
Could you please help me understand why this error is occurring and how to resolve it? Thank you in advance for your assistance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
This usually works fine, Next.js embeds its own version of the React canary releases that includes this upcoming feature. Could it be that yarn or your webpack config resolves React another way that doesn't point to that internal version? |
Beta Was this translation helpful? Give feedback.
Yes, you were right! After commenting out all the code that used nuqs, the error disappeared.
However, new issues emerged, which I had to address. The main issues were:
Build optimization failed: found pages without a React Component as default export in various file paths (.src/pages/*). The solution was to recognize that the pages directory was being mistaken for routing pages. Changing pages to routes resolved this issue.
There was also a TypeScript error.
After addressing these issues, the build was successful!
Then, I decided to reintroduce the nuqs code, and to my surprise, the build continued to be successful!
Thank you so much for such a wonderful library!