用于退出的命令是什么?(即终止Node.js进程)


当前回答

退出

let exitCode = 1;
process.exit(exitCode)

有用的退出代码

1 - Catchall for general errors
2 - Misuse of shell builtins (according to Bash documentation)
126 - Command invoked cannot execute
127 - “command not found”
128 - Invalid argument to exit
128+n - Fatal error signal “n”
130 - Script terminated by Control-C
255\* - Exit status out of range

其他回答

添加

process.exit(1);

会帮你的

我可以通过键入taskkill-F-IM node.exe,让我的所有节点进程直接从Windows 10上的Git Bash shell中消亡-这将立即结束我计算机上的所有节点过程。我发现我也可以使用taskkill//F//IM node.exe。不确定为什么-和//在这种情况下都有效。希望这有帮助!

在命令行中,.ext是您想要的:

$ node
> .exit
$

它记录在REPL文档中。REPL(Read Eval Print Loop)是Node命令行的名称。

在正常程序中,使用process.ext([code])。

打开运行节点应用程序的命令行终端,然后按Ctrl+C

如果要从代码中退出node js应用程序,

process.exit(); // graceful termination 
process.exit(1); // non graceful termination 

退出

let exitCode = 1;
process.exit(exitCode)

有用的退出代码

1 - Catchall for general errors
2 - Misuse of shell builtins (according to Bash documentation)
126 - Command invoked cannot execute
127 - “command not found”
128 - Invalid argument to exit
128+n - Fatal error signal “n”
130 - Script terminated by Control-C
255\* - Exit status out of range