Errors

ERR_INVALID_ARG_TYPE

An API receives a value of an unsupported type. Validate or convert at the input boundary rather than catching all TypeErrors indiscriminately. Tested on Node.js 22.16.0. Example output (one line per entry): ["ERR_INVALID_ARG_TYPE", "42"].

Formal Syntax & Structure

nodejs syntaxnodejs
error.code === "ERR_INVALID_ARG_TYPE"

Return Value

Error

Observed error classification; successful correction has its own return value.

Working Example

Example Snippetnodejs
try {    Buffer.from(42);}catch (e) {    console.log(e.code);}console.log(Buffer.from(String(42)).toString());
Node.js Reference