next.js: Cannot build with URL.canParse function
Link to the code that reproduces this issue
https://github.com/Semanual/canparse_github_issue
To Reproduce
- Run
npm run build - It throws an error “Property ‘canParse’ does not exist”
Current vs. Expected behavior
Current: An error is thrown, as if function URL.canParse didn’t exist.
Expected: Should build with no problems, as per mozilla docs this function is built-in.
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #44~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon May 22 13:39:36 UTC 2
Available memory (MB): 15852
Available CPU cores: 16
Binaries:
Node: 22.1.0
npm: 10.7.0
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
next: 14.3.0-canary.40 // Latest available version is detected (14.3.0-canary.40).
eslint-config-next: N/A
react: 18.3.1
react-dom: 18.3.1
typescript: 5.1.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
I tested with next dev too, and it works as expected. For some reason, it only gives this error in next build.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 20 (9 by maintainers)
Downgrade the next version from 14.2.11 to 14.2.10. It works for me. Same version test of node.
The issue happens with next v14.2.11 even with
next dev, while still working with 14.2.10, which makes 14.2.11 an unstable version for me. Tested with node.js LTS 20.17.0 and the latest version 22.8.0Fixed in #70215 , we’ll plan to backport the change to fix the regression on 14.2.11
Try to upgrade ‘@types/node’
Try this. I ran this command to update the NextJS version. It helped me resolve this error after one day of debugging.
npm i next@rc react@rc react-dom@rc eslint-config-next@rc --force