333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
## getpass
 
Get a password from the terminal. Sounds simple? Sounds like the `readline`
module should be able to do it? NOPE.
 
## Install and use it
 
```bash
npm install --save getpass
```
 
```javascript
const mod_getpass = require('getpass');
```
 
## API
 
### `mod_getpass.getPass([options, ]callback)`
 
Gets a password from the terminal. If available, this uses `/dev/tty` to avoid
interfering with any data being piped in or out of stdio.
 
This function prints a prompt (by default `Password:`) and then accepts input
without echoing.
 
Parameters:
 
 * `options`, an Object, with properties:
   * `prompt`, an optional String
 * `callback`, a `Func(error, password)`, with arguments:
   * `error`, either `null` (no error) or an `Error` instance
   * `password`, a String