TypeError: URL is not a constructor

Anyone know how to fix this error? It came out of no where as I was building my create-next-app@latest.

Things I've tried:

  • Restarted VS code and Mac
  • Deleted .next, package-lock.json and node_modules then reinstalled
  • Prompted GPT-4 to death trying to find solution...
  • Slept on it over night hoping I would wake up and the problem would be gone
  • First: commented out recently written code to try narrow down the problem cause
  • Second: started stripping my whole app trying to find anything that was causing it.
  • Third: my app is now pretty much a home page with stripped functionality and commented out endpoints, still got the error
  • Come to the conclusion that theres no way it can be from my actual written code, especially since the error is in next source files
  • Scoured YT and forms for answer... nothin.
Any help is really appreciated, its stopped me dead in my tracks, can't proceed without fixing. Page says: Internal server error.

Extra:

After restarting VS code, it fixes it, only temporarily until I start navigating on the page or using any functionality, or even refreshing, it immediately breaks and throws the same error.

ERROR MESSAGE:
TypeError: URL is not a constructor
    at parseRelativeUrl (/Users/admin/Desktop/stuff/devWork/inter-ai-next/node_modules/next/dist/shared/lib/router/utils/parse-relative-url.js:14:24)
    at parseUrl (/Users/admin/Desktop/stuff/devWork/inter-ai-next/node_modules/next/dist/shared/lib/router/utils/parse-url.js:15:55)
    at DevServer.handleRequestImpl (/Users/admin/Desktop/stuff/devWork/inter-ai-next/node_modules/next/dist/server/base-server.js:335:48)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)


Nothing in dev tools console, nothing in network, the above error is all I have.
Was this page helpful?