[英]how to use prompt function in node.js like in chrome
when I use chrome, I can use prompt function like 当我使用chrome时,可以使用提示功能
let name = prompt('What's your name?');
but when I use atom editor which use node.js as a compiler(i'm not sure this is called 'compiler'), the prompt function doesn't work. 但是当我使用原子编辑器将node.js用作编译器时(我不确定这称为“编译器”),提示功能不起作用。
I already tried to install 'prompt for node.js' at NPM but it still doesn't work. 我已经尝试在NPM上安装“提示输入node.js”,但仍然无法正常工作。
Please help me.... 请帮我....
Try this: 尝试这个:
var prompt = require('prompt');
//
// Start the prompt
//
prompt.start();
//
// Get two properties from the user: username and email
//
prompt.get(['username', 'email'], function (err, result) {
//
// Log the results.
//
console.log('Command-line input received:');
console.log(' username: ' + result.username);
console.log(' email: ' + result.email);
});
This is the result: 结果如下:
I'm using Visual Studio Code, however, the result's properly the same. 我正在使用Visual Studio Code,但是结果完全一样。 For more information, see this: https://www.npmjs.com/package/prompt
有关更多信息,请参见: https : //www.npmjs.com/package/prompt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.