-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when using the "Unified (router-agnostic)" imports (Error: Cannot find module '/node_modules/next/navigation'…
)
#869
Comments
Thanks for the report, it looks like we need to be smarter and lazy load the correct adapter, as the pages router needs to import from That or rework the pages router so that it doesn't use |
I tried reproducing the error in the e2e test bench, but I don't see any errors (see PR #878). I thought I had |
In this case it was |
@tordans & @rettgerst: There should be a fix for this issue in PR #917 (the pages router adapter now uses
|
🎉 This issue has been resolved in version 2.4.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@franky47 This error is still happening for me in v2.4.1:
I was able to resolve the issue with this patch (using patch-package): diff --git a/node_modules/nuqs/dist/chunk-C3RNEY2H.js b/node_modules/nuqs/dist/chunk-C3RNEY2H.js
index 3f7c2c6..89d4aa8 100644
--- a/node_modules/nuqs/dist/chunk-C3RNEY2H.js
+++ b/node_modules/nuqs/dist/chunk-C3RNEY2H.js
@@ -1,5 +1,5 @@
import { debug, renderQueryString } from './chunk-5WWTJYGR.js';
-import { useRouter, useSearchParams } from 'next/navigation';
+import { useRouter, useSearchParams } from 'next/navigation.js';
import { useOptimistic, useCallback, startTransition } from 'react';
function useNuqsNextAppRouterAdapter() { |
So that the agonostic adapter is happy about the import when bundled under the pages router. Closes #869.
@jdpnielsen thanks, can you try the following preview build (which is basically what your patch did) please?
|
Tested it, and it works! |
Context
What's your version of
nuqs
?What framework are you using?
Which version of your framework are you using?
Description
I migrated from
"nuqs": "1.20.0"
to"nuqs": "2.3.1"
and followed the https://github.com/47ng/nuqs/blob/next/errors/NUQS-404.md docs to useimport { NuqsAdapter } from 'nuqs/adapters/next'
since we are using both, the pages and app folder.I changed the imports to use the separate
/app
and/pages
imports in the corresponding files and the error was gone.Suggestion
Reevaluate the section https://nuqs.47ng.com/docs/adapters#nextjs-unified of the docs, it looks like that does not work as intended
The text was updated successfully, but these errors were encountered: