node print stdin 1

node print stdin

const process = require("process")
process.stdin.on('data', data => {
    console.log(data.toString())
})

Here is what the above code is Doing:
1. We’re importing the process module.
2. We’re using the process.stdin.on() method to listen for data events.
3. We’re using the console.log() method to print the data to the console.

Now, let’s run the above code:

$ node read_stdin.js

Hello World

Similar Posts