> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/nodejs/userland-migrations/llms.txt
> Use this file to discover all available pages before exploring further.

# util._extend to Object.assign

> Migrate deprecated util._extend() to Object.assign() for Node.js DEP0060

This recipe transforms the usage of deprecated `util._extend()` to use `Object.assign()` to handle Node.js [DEP0060](https://nodejs.org/api/deprecations.html#DEP0060).

## What It Does

This codemod replaces:

* `util._extend()` calls with `Object.assign()`
* Removes unnecessary `util` imports when no longer needed

## Before/After

**Before:**

```javascript theme={null}
const util = require("node:util");
const target = { a: 1 };
const source = { b: 2 };
const result = util._extend(target, source);
```

**After:**

```javascript theme={null}
const target = { a: 1 };
const source = { b: 2 };
const result = Object.assign(target, source);
```

## Usage

Run this codemod on your project:

```bash theme={null}
npx codemod node/userland/util-extend-to-object-assign
```

<Tip>
  `Object.assign()` is the standard ECMAScript method for copying properties from one or more source objects to a target object. It's more widely supported and follows JavaScript standards.
</Tip>

<Warning>
  Both `util._extend()` and `Object.assign()` mutate the target object. If you need a non-mutating merge, use the spread operator: `const result = { ...target, ...source }`.
</Warning>

## Related Deprecations

* [DEP0060: util.\_extend()](https://nodejs.org/api/deprecations.html#DEP0060)
