I tried to run the following code from the command prompt:
const read = require('read').read;
const password = await read({
prompt: "Password: ",
silent: true,
replace: "*" //optional, will print out an asterisk for every typed character
});
console.log("Your password: " + password);
with the command node read.js
and got:
SyntaxError: await is only valid in async functions and the top level bodies of modules
What should I do to make this work?
Should I add exports
or something like this?
I simply want it to read the password from the command line and print it.