Error code

Node.js ERR_INVALID_URL

NODE.JSERR_INVALID_URL
Runtime Error Code· An error code from a programming runtime or package manager, like Node.js or npm.

What it means

A string could not be parsed as a valid URL by the WHATWG URL API.

How to fix it

  1. Validate the URL with a try/catch around new URL().
  2. Check for missing protocol (http:// or https://).
  3. Use URL.canParse() (Node 19+) to test before constructing.

Not affiliated with Node.js. Answer summarized from the manufacturer's manual linked above; consult that source for the authoritative procedure.