Noah
Noah

Reputation: 4751

Capture CLI input silently with Node (i.e. hide password input)

I am making a CLI app that takes a user's password. I would not like the password to appear on the screen as they type. It should display a placeholder, or nothing at all. Such as:

$ node myapp.js
Please enter your email: [email protected]
Please enter your password: ******

EDIT: I was using the read package before, but marking input as silent: true does not work with nodemon.

Upvotes: 1

Views: 556

Answers (1)

Noah
Noah

Reputation: 4751

You can use the node packages, read or prompt. Keep in mind, they don't work with nodemon. They work, but the password will still be displayed when run with nodemon. This should only affect development since end users will run it with simply node.

Upvotes: 1

Related Questions