Search code examples
node.jsbasherror-handlingstdoutstderr

What is the difference between error, stderr, stdout in node


I am using node.js and want to handle error messages. What are the differences between erro, stderr, stdout?

When scripting shell, I redirected stderr and found useful error message and it solved the problem.

I am not clear about the concept of what kind of outputs computer have either. Can anyone explain in a comprehensive way?

Thanks.


Solution

  • stderr and stdout are streams. Writing to console will log both streams. Apparently the distinction exists between them so we that if we want to (for example) redirect certain data elsewhere, we have the ability to be selective.

    You may find the following article helpful.

    http://www.jstorimer.com/blogs/workingwithcode/7766119-when-to-use-stderr-instead-of-stdout