The process
module provides access to the standard I/O pipes for the process stdin
, stdout
, and stderr
. stdin
is the standard input pipe for the process, which is typically the console. That means that you can read input from the console by using the following code:
process.stdin.on('data', function(data){
console.log("Console Input: " + data);
});
Then when you type in data to the console and press Enter, the data is written back out. For example:
some data
Console Input: some data
The stdout
and stderr
attributes of the process module are Writable
streams that can be treated accordingly.