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

> webpack-cli@7.2.3 is a CommonJS package. CommonJS — require() works on every Node.js version we test.

CLI for webpack & friends

Last verified Sep 9, 2026 against webpack-cli@7.2.3.

webpack-cli ships CommonJS only. require("webpack-cli") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=20.9.0. import "webpack-cli" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

## What to do

1. require("webpack-cli") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=20.9.0.
2. From ES modules use the default import: import webpackCli from "webpack-cli"; then destructure. Named imports only work when Node.js can statically detect the exports.
3. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 7.2.3 (Aug 28, 2026)
- Module format: CommonJS
- Last CommonJS version: 7.2.3
- TypeScript types: bundled
- Node engines: >=20.9.0
- Weekly downloads: 10.0M
- License: MIT

## Runtime test results for webpack-cli@7.2.3

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

| Runtime | require("webpack-cli") | import "webpack-cli" |
|---|---|---|
| Node.js 18 | works | works |
| Node.js 20 | works | works |
| Node.js 22 | works | works |
| Node.js 24 | works | works |
| Node.js 26 | works | works |
| Bun 1.4.0 | works | works |

## How to import webpack-cli

ES modules:

```js
import webpackCli from "webpack-cli";
```

CommonJS:

```js
const webpackCli = require("webpack-cli");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 3.0.4 – 7.2.3 | CommonJS | Jun 12, 2018 |

## Frequently asked

**Is webpack-cli ESM-only?**

webpack-cli@7.2.3 is a CommonJS package. webpack-cli ships CommonJS only. require("webpack-cli") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=20.9.0. import "webpack-cli" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

**Can I import webpack-cli with ES module syntax?**

Yes. import webpackCli from "webpack-cli" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

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

Yes. import "webpack-cli" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

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

Yes. webpack-cli bundles its own type declarations; no @types package is needed.

## Links

- [webpack-cli on npm](https://www.npmjs.com/package/webpack-cli)
- [Source repository](https://github.com/webpack/webpack-cli)
- [HTML version](https://canirequire.com/package/webpack-cli/)
- [JSON version](https://canirequire.com/package/webpack-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.
