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...

  • Press Ctrl + C twice, or
  • type .exit and press Enter, or
  • press Ctrl + D at the start of a line (Unix only)
  • 链接地址: http://www.djcxy.com/p/1518.html

    上一篇: C#的隐藏特性?

    下一篇: 如何在Node.js中退出