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. 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.
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 | ✗ 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.1Module 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 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
- 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 - tslib 2.8.1last CJS
2.5.2 - string-width 8.2.2last CJS
4.2.3 - ansi-regex 6.3.0last CJS
5.0.1
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
- rollup-plugin-copy 3.5.0CommonJS
- optimize-css-assets-webpack-plugin 6.0.1CommonJS
- replace-in-file 9.0.0ESM-only
- stylus-loader 9.0.0Dual