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.

5

2 Answers

It is actually an interesting question. You would probably get more answers if you format the title of your question like this -- Node JS difference between error, stderr, and stdout.
I won't repeat the difference between stdout and stderr, as it is answered previously.

However, the difference between error and stderr is not that easily distinguished.

Error is an error object created by Node JS because it is having a problem executing your command. See more here

Stderr is a standard output stream that happens because something is wrong during execution -- that is Node JS has no trouble executing your command, it is your command itself throws the error.

Let me know if this is clear, otherwise, I'm happy to throw in an example:)

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest