Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

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

node command line input

process.stdin.on('data', (data) => {
	console.log(`You typed ${data}`);
})
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 :: how to use for of in javascript 
Javascript :: mongoose find get nested prop only 
Javascript :: javascript how to deal with %20 in string 
Javascript :: react maps 
Javascript :: javascript add text to textarea overwrite 
Javascript :: type coercion 
Javascript :: javascript array randomizer 
Javascript :: map a square to a circle 
Javascript :: how to convert a string to a mathematical expression programmatically javascript 
Javascript :: jquery.mask.js 
Javascript :: jquery window new tab with post 
Javascript :: random unique number generator javascript 
Javascript :: js falsy values 
Javascript :: Javascript format date / time 
Javascript :: how to add multiple elements to A new array javascript 
Javascript :: How to fetch data from an api async and await 
Javascript :: thymeleaf pass variable to javascript 
Javascript :: jquery if else 
Javascript :: angular img tag 
Javascript :: setProps jest 
Javascript :: Connect MSSQL With JavaScript 
Javascript :: react currency format method 
Javascript :: get all parent nodes of child in javascript array 
Javascript :: longitud objeto javascript 
Javascript :: if array ontains any item of another array js 
Javascript :: how to sum variables to an array in javascript 
Javascript :: javascript check if array is empty or null or undefined 
Javascript :: js two value from array after reduce 
Javascript :: string charat javascript 
Javascript :: sort by attribute in reactjs 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =