How to exit in Node.js
What is the command that is used to exit? (ie terminate node.js process)
Call the global process
object's exit
method:
process.exit()
From the docs:
process.exit([code])
Ends the process with the specified code
. If omitted, exit uses the 'success' code 0
.
To exit with a 'failure' code:
process.exit(1);
The shell that executed node should see the exit code as 1.
From the official nodejs.org documentation:
process.exit(code)
Ends the process with the specified code. If omitted, exit uses the 'success' code 0.
To exit with a 'failure' code:
process.exit(1);
If you're in a Unix terminal or Windows command line and want to exit the Node REPL, either...
.exit
and press Enter, or 上一篇: C#的隐藏特性?
下一篇: 如何在Node.js中退出