Reputation: 179
I have created a simple program for process.stdin and process.stdout. But when i run the program and enter the value for stdout, it shows Error "TypeError: "encoding" must be a valid string encoding". Here is my code .
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
process.stdout.write("Data >>>>", chunk);
});
process.stdin.on('end', function() {
process.stderr.write("End!!!");
});
Can anyone tell me what is wrong with program.
Upvotes: 2
Views: 1129
Reputation: 29102
This line passes 2 arguments to write
:
process.stdout.write("Data >>>>", chunk);
The second argument will be treated as an encoding, not as extra data to write.
Upvotes: 1