I am relatively new to JavaScript and I can't get NPM to work when trying to install prompt. I am trying to code a program that takes user input from the console and convert it into other variables. What it is supposed to do is ask for the temperature in Fahrenheit take your input and then convert it into Celsius and Kelvin. Does anybody know how to get the prompt command?
if you would like to read a user input, you can use readline
node modules
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.question('What do you think of Node.js? ', (answer) => {
// TODO: Log the answer in a database
console.log(`Thank you for your valuable feedback: ${answer}`);
rl.close();
});
for more details, see How do I prompt users for input from a command-line script?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.