阻止节点进程退出的最简单的代码量是多少?

What is the simplest amount of code that would prevent a node process from exiting?

我正在寻找一种在终端的 javascript node.js 文件中记录文本并且不退出该进程的方法。

console.log('hello-world')
process.doNotExit()

我过去做过很多不同的事情,例如连接到数据库以防止进程退出。

我正在寻找与 forever 模块不同的东西。

您可以使用 setInterval 而什么都不做:

var i= setInterval(function(){}, 2147483647);

数值来自here,大约是25天。
准备退出时使用 clearIntervalunref(有关详细信息,请参阅 here)。

天真,但很简单。不是吗?