How to exit a Node.js program?

Sometimes, we want to exit a Node.js program.

In this article, we’ll look at how to exit a Node.js program.

How to exit a Node.js program?

To exit a Node.js program, we can call process.exit.

For instance, we run

process.exit()

to exit the program without any exit code.

Or we can write

process.exit(1)

to exit the Node.js program with exit code 1.

Conclusion

To exit a Node.js program, we can call process.exit.