# detect-usb

> Detect USB and get mount points/paths

Latest version **3.0.0** (published 2023-12-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install detect-usb
pnpm add detect-usb
yarn add detect-usb
bun add detect-usb
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2023-12-18 |
| First published | 2020-04-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | sudhakar3697 |
| Maintainers | sudhakar3697 |
| Keywords | usb, usb-detect, usb-detection, detect-usb, usb-events |

## Links

- npm: https://www.npmjs.com/package/detect-usb
- Repository: https://github.com/sudhakar3697/detect-usb
- Homepage: https://github.com/sudhakar3697/detect-usb#readme
- Issues: https://github.com/sudhakar3697/detect-usb/issues
- npm.io page: https://npm.io/package/detect-usb

## Dependencies (2)

- [drivelist](https://npm.io/package/drivelist.md) ^11.1.0
- [usb-detection](https://npm.io/package/usb-detection.md) ^4.14.2

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 3.0.0 (latest) — 2023-12-18
- 2.0.0 — 2020-04-07
- 1.0.0 — 2020-04-03

## README

# detect-usb
Detect USB and get mount points/paths

## Usage

```javascript
const usbEvents = require('detect-usb');

// To start listening
usbEvents.startListening();

// To get list of connected USBs
(async () => {
    console.log(await usbEvents.getUSBList());
})();

usbEvents.on('insert', (data) => {
    console.log(data);
})

usbEvents.on('eject', (data) => {
    console.log(data);
})

// To stop listening
usbEvents.stopListening();
```

## Sample Data

```json5
{ 
event: 'insert',
data:
    { 
        key: '/media/test/sss',
        name: 'sss',
        devicepath: '/dev/sda',
        isAccessible: true 
    } 
}

{ event: 'eject', data: { key: '/media/test/sss' } }
```

## Note

* Verified on Windows & Linux
* Uses [usb-detection](https://www.npmjs.com/package/usb-detection) & [drivelist](https://www.npmjs.com/package/drivelist)

---
_Source: https://npm.io/package/detect-usb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
