> ## 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.

# process.assert to node:assert

> Migrate from process.assert to the node:assert module (DEP0100)

This recipe transforms usage of the deprecated `process.assert` to the proper `node:assert` module.

## Deprecation

Node.js deprecated `process.assert` in favor of the dedicated `node:assert` module.

See [DEP0100](https://nodejs.org/api/deprecations.html#DEP0100) for more details.

## Usage

Run this codemod with:

```bash theme={null}
npx codemod nodejs/process-assert-to-node-assert
```

## Before/After

<Tabs>
  <Tab title="ESM">
    ```diff theme={null}
    + import assert from "node:assert";
    - process.assert(condition, "Assertion failed");
    + assert(condition, "Assertion failed");
    ```
  </Tab>

  <Tab title="CommonJS">
    ```diff theme={null}
    + const assert = require("node:assert");
    - process.assert(condition, "Assertion failed");
    + assert(condition, "Assertion failed");
    ```
  </Tab>
</Tabs>

## What It Does

* Replaces `process.assert()` calls with `assert()` from `node:assert`
* Automatically adds the appropriate import/require statement
* Detects whether your project uses ESM or CommonJS by reading `package.json`
* Preserves assertion arguments and error messages

## Smart Import Detection

This codemod uses the [`fs` capability](https://docs.codemod.com/jssg/security) to read your `package.json` file and determine if the project uses ES modules or CommonJS. Based on this information, it adds the appropriate import statement:

* If `"type": "module"` is present, it adds: `import assert from "node:assert";`
* Otherwise, it adds: `const assert = require("node:assert");`

<Tip>
  The `node:assert` module provides a full suite of assertion functions including `assert.strictEqual()`, `assert.deepEqual()`, `assert.throws()`, and more.
</Tip>
