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 % 

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap