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

input from terminal node js

// npm i readline-sync
import readlineSync from 'readline-sync';

const text = readlineSync.question('enter text:');

const password = readlineSync.question('password:', {
  hideEchoBack: true // The typed text on screen is hidden by `*` (default).
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery disable button 
Javascript :: double question mark javascript 
Javascript :: jquery $(...)..each() is not a function 
Javascript :: style before javascript 
Javascript :: jquery get unique values from array 
Javascript :: Custom jquery validation messages 
Javascript :: immutable array sort javascript 
Javascript :: Using "requireCordovaModule" to load non-cordova module "xcode" is not supported 
Javascript :: are you sure javascript 
Javascript :: how select just before element in jquery 
Javascript :: jquery datatables get selected row data 
Javascript :: js remove query param from url 
Javascript :: check if number is single digit javascript 
Javascript :: read from s3 bucket nodejs 
Javascript :: javascript create element in a new line 
Javascript :: remove element from an array 
Javascript :: js history back 
Javascript :: js keydown only once 
Javascript :: copywithin javascript 
Javascript :: js check if element hidden 
Javascript :: JAVASCRIPT ARRRAY LOOP BACKWARDS 
Javascript :: parse local json file 
Javascript :: Convert a string to an integer in jQuery 
Javascript :: angular access current scope from console 
Javascript :: Module Error (from ./node_modules/eslint-loader/dist/cjs.js): 
Javascript :: js div detect change 
Javascript :: loop dictionary with key and value javascript 
Javascript :: how to get date using tolocaledatestring 
Javascript :: new nextjs project 
Javascript :: copy dict js 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =