On this page

    C

    RangeError

    History
    class RangeError extends errors.Error

    Indicates that a provided argument was not within the set or range of acceptable values for a function; whether that is a numeric range, or outside the set of options for a given function parameter.

    require('node:net').connect(-1);
    // Throws "RangeError: "port" option should be >= 0 and < 65536: -1"

    Node.js will generate and throw RangeError instances immediately as a form of argument validation.