canirequire

canirequire › ESM-only › postcss-cli

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

CLI for PostCSS

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

ESM-only ESM-only since 9.0.0 — last CommonJS version is 8.3.1

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

Does postcss-cli@12.0.0 actually load? Runtime test results

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

Runtimerequire("postcss-cli")import "postcss-cli"
Node.js 18✗ failsERR_REQUIRE_ESM✗ failsSyntaxError
Node.js 20✗ failsERR_REQUIRE_ASYNC_MODULE✗ failsError
Node.js 22✗ failsERR_REQUIRE_ASYNC_MODULE✗ failsError
Node.js 24✗ failsERR_REQUIRE_ASYNC_MODULE✗ failsError
Node.js 26✗ failsERR_REQUIRE_ASYNC_MODULE✗ failsError
Bun 1.4.0✗ failsError✗ failsError

How to import postcss-cli

ES modules (import)

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 (require)

// 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, corrected where a runtime test of that version contradicted them (58 versions; the newest 58 shown).

VersionsFormatFirst published
9.0.0 – 12.0.0ESM-onlySep 24, 2021
0.1.0 – 8.3.1CommonJSMar 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

Other esm-only packages

Similar popularity