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 separate words by capital letter 
Javascript :: faker npm 
Javascript :: firebase realtime database delete child 
Javascript :: how to replace commas with nothing in javascript 
Javascript :: how to get text which is in input td using jquery 
Javascript :: Add event listener to multiple buttons with the same class 
Javascript :: express post body 
Javascript :: usehistory example 
Javascript :: strart a nextjs project 
Javascript :: socket io broadcast to room 
Javascript :: javascript log error without traceback 
Javascript :: fakepath 
Javascript :: javascript read xlsx file 
Javascript :: nods js fs append to file 
Javascript :: convert string to datetime javascript 
Javascript :: js insert string at position 
Javascript :: Javascript - check if div contains a word? - Stack Overflow 
Javascript :: javascript regex replace all 
Javascript :: array has object with property js 
Javascript :: javascript loop through object 
Javascript :: how to get utc time in angular 
Javascript :: random light color js 
Javascript :: gatsby-plugin-create-client-paths 
Javascript :: how to make a bot react to own message js 
Javascript :: Uncaught ReferenceError: axios is not defined 
Javascript :: how to start json server 
Javascript :: express server template 
Javascript :: set focus on input field javascript 
Javascript :: day name date js 
Javascript :: give div event listener functional component 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =