Fix: Uncaught ReferenceError: exit is not defined - Node.js REPL

If you are trying to exit the Node.js REPL (Read-Eval-Print Loop) environment by typing exit, you will get the below error.

Code2care@Mac % node
Welcome to Node.js v20.4.0.
Type ".help" for more information.
> 
> exit
Uncaught ReferenceError: exit is not defined

The command command to exit Node REPL is .exit

> .exit

Code2care@Mac % 
Fix - Uncaught ReferenceError- exit is not defined

If you are on a Mac, you can also press Control + Z to suspended node and comeback to your Terminal prompt.

> 
zsh: suspended  node
Code2care@Mac % 

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!