modernweb-dev / web

Guides, tools and libraries for modern web development.
https://modern-web.dev
MIT License
2.15k stars 271 forks source link

TypeError: URL.canParse is not a function #2746

Closed BHDBvde closed 1 month ago

BHDBvde commented 1 month ago

When using a URL.canParse in code, running a test with the latest version of web-test-runner gives me this error:

TypeError: URL.canParse is not a function

Used node version: >20

Why is this not working?

bashmish commented 1 month ago

it's a recent feature that requires a polyfill in some browsers https://developer.mozilla.org/en-US/docs/Web/API/URL/canParse_static

if you only test in latest browsers, maybe just update your dependencies to use the latest image

alternatively, you can add a polyfill, check this README https://github.com/modernweb-dev/web/tree/master/packages/dev-server-polyfill

I think we can close this since this is not a bug