2

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.

0

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Yeah...I would also add to fix use process.stdout.write("Data >>>>" + chunk);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.