Support for the 'readline' module in node.js
TheCoiledViper (36)

For a project, I'm trying to use the readline module to scan user inputs, but every time there seems to be an error. I even copied a code snippet from 'node.readthedocs.io' (https://repl.it/@TheCoiledViper/Nodejs-Readline-Module) , but it still brought an error. On other node.js online editors like jdoodle, the code seems runs without errors.

You are viewing a single comment. View All
JoshuaKing1 (6)
const readline = require('readline-sync');
var userinput = 0;
userinput = readline.question(`Enter name:\n`);
console.log("Hello,",userinput,"!")

should help the problem. Running it on this compiler is a bit different. It will first install a package which will allow it to get users input. Hope it helps! (check it answered if it works)