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
- 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.
- 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).
- 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.
- postcss-cli@12.0.0 declares engines ">=22", so Node.js 18, 20 are unsupported regardless: upgrade Node.js or pin an older release.
- TypeScript: no types are available for postcss-cli; declare the module yourself if you need them.
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.
| Runtime | require("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.1Module 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).
| 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
Other esm-only packages
- ansi-styles 7.0.0last CJS
5.2.0 - strip-ansi 7.2.0last CJS
6.0.1 - commander 15.0.0last CJS
14.0.3 - supports-color 11.0.0last CJS
8.1.1 - chalk 6.0.0last CJS
4.1.2 - string-width 8.2.2last CJS
4.2.3 - ansi-regex 6.3.0last CJS
5.0.1 - escape-string-regexp 5.0.0last CJS
4.0.0
Similar popularity
- babel-plugin-transform-async-to-generator 6.24.1CommonJS
- json-loader 0.5.7CommonJS
- grunt 1.6.3CommonJS
- @ethersproject/providers 5.8.0CommonJS
- @vue/eslint-config-prettier 10.2.0CommonJS
- rollup-plugin-copy 3.5.0CommonJS
- optimize-css-assets-webpack-plugin 6.0.1CommonJS
- replace-in-file 9.0.0ESM-only