Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

input in node js

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
 
readline.question('who are you: ', name => {
	console.log(`hello, hi there ${name}`);
	readline.close();
})
Comment

getting user input in node js

//Make sure you have Node and NPM installed
//Run "npm install prompt-sync" in the terminal
const prompt = require('prompt-sync')();

const name = prompt('What is your name?');
console.log(`Hey there ${name}`);
Comment

get input in terminal nodejs

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

readline.question('Who are you?', name => {
  console.log(`Hey there ${name}!`);
  readline.close();
});
Comment

how to take input from user nodejs

const prompt = require("prompt-sync")();

const input = prompt("What is your name? ");

console.log(`Oh, so your name is ${input}`);
Comment

node js get input from console

--------------- easiest method I found---------------------------
  
Run npm install prompt-sync in the terminal
const prompt = require('prompt-sync')();

var name = prompt('what is your name?');

console.log(name);

--------------------------------------------------------------
Comment

Nodejs user input

// Importing the module
const readline = require("readline-sync");
  
// Enter the number
let a = Number(readline.question());
let number = [];
for (let i = 0; i < a; ++i) {
  number.push(Number(readline.question()));
}
console.log(number);
Comment

get user input Node js console

// first install prompt-sync:
// npm install prompt-sync

const prompt = require("prompt-sync")({ sigint: true });

const age = prompt("How old are you? ");
console.log(`You are ${age} years old.`);
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript typeof undfined 
Javascript :: python dictionary to json 
Javascript :: useeffect will unmount 
Javascript :: javascript check if array is empty 
Javascript :: dom key event shift is pressed 
Javascript :: how to empty an element in javascript 
Javascript :: How to change favicon in nextjs. 
Javascript :: javascript check if value is not empty string 
Javascript :: javascript object toarray 
Javascript :: how to check if a json object contains a key in jquery 
Javascript :: nextjs tailwind 
Javascript :: htmlWebpackPlugin.options.title 
Javascript :: adding integers jquery 
Javascript :: pattern telefone js 
Javascript :: js get user location 
Javascript :: import fa icons react 
Javascript :: get quizlet coursehero free 
Javascript :: equivalent of useHistory in react 
Javascript :: how to run react build locally 
Javascript :: jquery click event 
Javascript :: on page fully loaded jquery 
Javascript :: check empty object 
Javascript :: javascript trim each element in array 
Javascript :: jquery wrap inner text 
Javascript :: jquery select radio by name 
Javascript :: javascript trigger button click using class name 
Javascript :: localstorage read all key 
Javascript :: round to nearest hundredth javascript 
Javascript :: how to format unix timestamp javascript 
Javascript :: js get selection start from contenteditable 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =