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 the scripting shell, I redirected stderr and found a useful error message, and he solved the problem.

I do not quite understand what computer outputs are. Can someone explain in a complex way?

Thanks.

+8
bash stdout stderr error-handling
source share
2 answers

stderr and stdout are streams. Writing to the console will record both streams. Apparently, there is a difference between the two, so we want that if we want (for example) to redirect certain data elsewhere, we can be selective.

You can find the following helpful article.

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

+1
source share

This is a really interesting question. You will probably get more answers if you format the name of your question as follows: Node JS the difference between the error, stderr and stdout.

I will not repeat the difference between stdout and stderr, as this is the answer earlier.

However, the difference between error and stderr is not so easy to distinguish.

An error is an error object created by Node JS because it has a problem executing your command. More here

Stderr is the standard output stream that occurs because something is wrong at runtime - this is Node. JS has no problems executing your command, it is your command that throws an error.

Let me know if this is clear, otherwise I'm glad to add an example :)

+5
source share

All Articles