next.js: [NEXT-978] `./app/[[...params]]/page.tsx` gives `SyntaxError: "undefined" is not valid JSON at JSON.parse ()`
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000
Binaries:
Node: 19.7.0
npm: 9.5.0
Yarn: N/A
pnpm: 7.29.1
Relevant packages:
next: 13.2.5-canary.0
eslint-config-next: 13.2.4
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue
trivial example below
To Reproduce
Create a trivial page
// ./app/[[..params]]/page.tsx
export default function Page(params) {
return <>hello</>
}
Describe the Bug
Doing so returns:
error - SyntaxError: "undefined" is not valid JSON
at JSON.parse (<anonymous>)
Note that if I remove the double bracket notation, the error goes away.
Expected Behavior
The opposite đ
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
next dev
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 18
- Comments: 38 (5 by maintainers)
Commits related to this issue
- Update Next.js to 13.2.4. Can't update to 13.3 due to https://github.com/vercel/next.js/issues/47024 — committed to Lakuna/Lakuna.github.io by Lakuna a year ago
if youâre using
"use client"
and face this error, use your function like this and then the error disappear:same issue when specifying âuse clientâ.
Ran into this as well in next 13.3.0 - triggered when using âuse clientâ on any page or component. Was non issue in last project, next 13.2.4
No fixes or workarounds yet
same for me, but when I first declare the function and after I export it works
This problem happened to me on windows but not on mac, with the same project
Upgrading to the lastest canary fixed my issue.
For some reason, doing function <func name> () { } and export default <func name> it works fine
Does not work, when I do const <func name> = () => {} or put the export along with the function declaration.
This happens on all pages, not just on dynamic ones.
Hi all! There seem to be multiple different reports in this thread, and I believe some of them have been fixed already. With the latest canary, I can no longer reproduce these problems on my machine:
1:
2:
If you are still getting an issue with latest canary (>= 13.3.1-canary.4), please share a reproduction with your Next.js version and operating system name. This will help me debugging the problem, thanks!
Same for me, using back the 13.2.4 solved the problem
This solution work for me too, need to apply it to all client comp/page. Only changed the export.
i was using latest version 13.3 faced the same issue multiple times but after changing the version to 13.2.4 everything is fine now
Upgraded to Next.js 13.3 and immediately encountered this issue. Reverted back to 13.2.4 and everything was fine again. The presence of error.tsx or global-error.tsx made no difference. To me it seemed like the error occured as soon as a client component tried to run. As in it wouldnât even run a console.log at the very start of the functional component.
I have the same issue
Iâm seeing this error on a freshly scaffolded 13.2.5-canary.30 app with providers wrapper even without fragments last working version for me is v13.2.5-canary.19 after that everything broke
removing âuse clientâ fixes it
providers.ts
layout.tsx
Hey,
I use next v13.2.4, Iâve got the same problem but on my two dynamic routes for the moment
app/[slug]
&app/[slug]/[product_slug]
. I guess it happens on routes with multiple dynamic args.Other information, i always get this error in production but rarely in development, and it happens after a manual reload of the current page.
the solution of error . Change package.json in dev : "next dev --turbo "
I have this problem after upgrading to 13.3.0, reverting back to 13.2.4 fixes it. Will wait for a hotfix.
Did you use ânpm install next@13.2.4â ? Simply changing your package.json next version and then just using npm install will not fix issue. Using ânpm install next@(version)â did work for me however, at least in development, have not used in production yet.
I had the same issue, was tearing my hair out trying to figure out what was causing it.
package.json dependencies:
Like others have suggested, when using
'use client'
you have to change the way that functions are exported to fix the problem.to instead
And for me, the issue was fixed.
I faced this issue with
next@13.3.0
. In my caseThis solved the issue but I started having other errors regarding hydration (content mismatch). Only happened on hard reload on the page. (app/q/[qid]/page.tsx)
I used
to bootstrap the application.
This solved the issue for me đ
Installing latest canary release manually solved the issue for me
Closing it then đ
this solution work for me.
The same trouble, while rolled back to the previous versionâŚ
having this issue even degrading to back to 13.2.4 which was working is giving me this error.