canirequire

canirequireESM-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. 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 you can require() on every Node.js version, including 18 and older, is 8.3.1, published Dec 12, 2020.

require("postcss-cli") fails even on Node.js 20.19+ / 22.12+ because the package uses top-level await, which require(esm) cannot load. Use import() instead.

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

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✗ failsInput Error: Did not receive any STDIN
Node.js 22✗ failsERR_REQUIRE_ASYNC_MODULE✗ failsInput Error: Did not receive any STDIN
Node.js 24✗ failsERR_REQUIRE_ASYNC_MODULE✗ failsInput Error: Did not receive any STDIN
Node.js 26✗ failsERR_REQUIRE_ASYNC_MODULE✗ failsInput Error: Did not receive any STDIN
Bun 1.4✗ failsInput Error: Did not receive any STDIN✗ failsInput Error: Did not receive any STDIN

How to import postcss-cli

ES modules (import)

import postcssCli from "postcss-cli";

CommonJS (require)

// Node.js 20.19+ / 22.12+ / newer (package has no top-level await):
const postcssCli = require("postcss-cli");

// Any Node.js version:
const postcssCli = await import("postcss-cli");

// Or pin the last CommonJS release:
// 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).

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 you can require() on every Node.js version, including 18 and older, is 8.3.1, published Dec 12, 2020.

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

8.3.1 is the last version of postcss-cli with a CommonJS build. 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?

Use a dynamic import: const mod = await import("postcss-cli"). On Node.js 20.19+, 22.12+ and newer, a plain require("postcss-cli") also works for ESM packages that do not use top-level await. Alternatively pin postcss-cli@8.3.1.

Does postcss-cli work in Bun?

Importing postcss-cli failed in Bun 1.4 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