我使用 AWS,并且希望使用 console.err()
将所有错误写入 stderr
。 stderr
被 AWS Cloud Watch 捕获并记录。我不想阻塞事件循环。
Node.js 实现中的 console.err()
是异步的吗?
最佳答案
这取决于操作系统以及 stderr
的“去向”。
process.stdout
andprocess.stderr
differ from other Node.js streams in important ways:
They are used internally by
console.log()
andconsole.error()
, respectively.Writes may be synchronous depending on what the stream is connected to and whether the system is Windows or POSIX:
- Files: synchronous on Windows and POSIX
- TTYs (Terminals): asynchronous on Windows, synchronous on POSIX
- Pipes (and sockets): synchronous on Windows, asynchronous on POSIX
关于javascript - Node.js:console.err() 是同步还是异步?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60987847/