节点守护进程不会以 process.stdin.setRawMode(true) 启动

Col*_*ati 3 daemon node.js raspberry-pi

我正在运行一个节点服务器守护进程,但我一直遇到这个错误。

当我运行 bash strip 来测试应用程序时,我得到TypeError: process.stdin.setRawMode is not a function.

你能帮我找到一种方法,我可以在这个节点应用程序在后台运行时使用键盘输入吗?

我试过给我的 bash 脚本权限chmod 777 x.sh&chmod 755 x.sh

Dan*_* W. 7

setRawMode()仅当输入由 TTY 提供而不是像您那样从stdin.

使用它来检查你有什么流:

if (process.stdin.isTTY) {
    process.stdin.setRawMode(true);
}
Run Code Online (Sandbox Code Playgroud)

还有其他关于您的问题的问题和答案,您可以使用 Google 或 Stackoverflow 搜索轻松找到。