# Is postcss-cli ESM-only? Can you require() it?

> postcss-cli@12.0.0 is ESM-only. ESM-only since 9.0.0 — last CommonJS version is 8.3.1.

CLI for PostCSS

Last verified Sep 9, 2026 against postcss-cli@12.0.0.

postcss-cli dropped its CommonJS build in 9.0.0 (September 2021). The last version with a plain require()-able CommonJS entry is 8.3.1, published Dec 12, 2020; it declares support for Node.js >=10.

require("postcss-cli") fails even on Node.js 22.12+ and newer: the package uses top-level await, which require(esm) cannot load (ERR_REQUIRE_ASYNC_MODULE). Use import() instead. Node.js 18 has no require(esm), and postcss-cli@12.0.0 declares Node.js >=22, so 18 is outside its supported range anyway.

postcss-cli@12.0.0 declares engines ">=22", so Node.js 18, 20 are outside its supported range regardless of module format.

## What to do

1. require("postcss-cli") fails even on Node.js 22.12+ and newer: the package uses top-level await, which require(esm) cannot load (ERR_REQUIRE_ASYNC_MODULE). Use import() instead.
2. From a CommonJS file, use a dynamic import inside an async function: const postcssCli = await import("postcss-cli"). That works on every Node.js version the package supports (>=22).
3. If you need a synchronous require() or run Node.js 18: npm install postcss-cli@8.3.1, the last CommonJS release (published Dec 12, 2020); it declares Node.js >=10.
4. postcss-cli@12.0.0 declares engines ">=22", so Node.js 18, 20 are unsupported regardless: upgrade Node.js or pin an older release.
5. TypeScript: no types are available for postcss-cli; declare the module yourself if you need them.

## Facts

- Latest: 12.0.0 (Sep 4, 2026)
- Module format: ESM-only
- Last CommonJS version: 8.3.1
- ESM-only since: 9.0.0 (Sep 24, 2021)
- TypeScript types: none
- Node engines: >=22
- Weekly downloads: 1.1M
- License: MIT

## Runtime test results for postcss-cli@12.0.0

Installed and executed on Sep 9, 2026 with require("postcss-cli") from a CommonJS file and import "postcss-cli" from an ES module.

| Runtime | require("postcss-cli") | import "postcss-cli" |
|---|---|---|
| Node.js 18 | fails (ERR_REQUIRE_ESM) | fails (SyntaxError) |
| Node.js 20 | fails (ERR_REQUIRE_ASYNC_MODULE) | fails (Error) |
| Node.js 22 | fails (ERR_REQUIRE_ASYNC_MODULE) | fails (Error) |
| Node.js 24 | fails (ERR_REQUIRE_ASYNC_MODULE) | fails (Error) |
| Node.js 26 | fails (ERR_REQUIRE_ASYNC_MODULE) | fails (Error) |
| Bun 1.4.0 | fails (Error) | fails (Error) |

## How to import postcss-cli

ES modules:

```js
import * as postcssCli from "postcss-cli";
```

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS:

```js
// Node.js 22.12+ and newer cannot require() this package: it uses top-level await.

// Any Node.js version the package supports (>=22), from an async function:
async function main() {
  const postcssCli = await import("postcss-cli");
}

// Or pin the last CommonJS release (declares Node.js >=10):
// npm install postcss-cli@8.3.1
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (58 versions; the newest 58 shown).

| Versions | Format | First published |
|---|---|---|
| 9.0.0 – 12.0.0 | ESM-only | Sep 24, 2021 |
| 0.1.0 – 8.3.1 | CommonJS | Mar 12, 2015 |

## Frequently asked

**Is postcss-cli ESM-only?**

postcss-cli@12.0.0 is ESM-only. postcss-cli dropped its CommonJS build in 9.0.0 (September 2021). The last version with a plain require()-able CommonJS entry is 8.3.1, published Dec 12, 2020; it declares support for Node.js >=10.

**Which version of postcss-cli still supports CommonJS / require()?**

8.3.1 is the last version of postcss-cli with a CommonJS build; it declares Node.js >=10. Install it with "npm install postcss-cli@8.3.1". Every version from 9.0.0 on is ESM-only.

**How do I use postcss-cli from a CommonJS file?**

From a CommonJS file, use a dynamic import inside an async function: const postcssCli = await import("postcss-cli"). That works on every Node.js version the package supports (>=22). require("postcss-cli") fails even on Node.js 22.12+ and newer: the package uses top-level await, which require(esm) cannot load (ERR_REQUIRE_ASYNC_MODULE). Use import() instead. Alternatively pin postcss-cli@8.3.1 (declares Node.js >=10).

**Does postcss-cli work in Bun?**

Importing postcss-cli failed in Bun 1.4.0 on Sep 9, 2026: Input Error: Did not receive any STDIN

**Does postcss-cli ship TypeScript types?**

No. postcss-cli ships no type declarations and there is no @types package for it.

## Links

- [postcss-cli on npm](https://www.npmjs.com/package/postcss-cli)
- [Source repository](https://github.com/postcss/postcss-cli)
- [HTML version](https://canirequire.com/package/postcss-cli/)
- [JSON version](https://canirequire.com/package/postcss-cli.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
