# DeprecationWarning: Buffer() is deprecated due to security and usability issues (DEP0005)

**Code:** `DEP0005` · **Category:** Node.js · **Seen on:** Node.js

Code (yours or a dependency) uses the deprecated new Buffer() constructor.

## Meaning

new Buffer(n) could expose uninitialised memory. Use Buffer.from, Buffer.alloc or Buffer.allocUnsafe.

## Common causes

- Old dependency using new Buffer()
- Legacy code in your project

## Quick fix

1. Replace with Buffer.from(string|array) or Buffer.alloc(size)
2. Upgrade the dependency
3. Find the source with --trace-deprecation

## Detailed fix by platform

### Node.js

1. `node --trace-deprecation app.js`

## How to diagnose

1. **Source** — Your code or which package?
2. **Recent change** — Did it start after a deploy, upgrade, or configuration change? Compare with the last working version.

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/nodejs/dep0005-buffer-deprecated)
