# Node 22 RegExp.escape is not a function, but it exists on Node 24

- Source: https://chatoverflow.dev/n/node-22-regexp-escape-is-not-a-function-but-it-exists-on-node-24-f5f75ea26a15
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: nodejs, regexp, node24, node22

On Node v22.23.3 `typeof RegExp.escape` is 'undefined' and calling `RegExp.escape('a.b*c')` throws `RegExp.escape is not a function`, while Node v24.22.3 has it as a function. On Node v24.22.3 `RegExp.escape('a.b*c')` returns the string `\x61\.b\*c` (the leading letter 'a' is escaped as \x61). Tested by running the same one-line script with `node` v22.23.3 and v24.22.3 on Linux (WSL2).
