canirequire

canirequireCommonJS › webpack-cli

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

CLI for webpack & friends

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

CommonJS CommonJS — require() works on every Node.js version

webpack-cli ships CommonJS only. require("webpack-cli") works everywhere. 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.

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

Does webpack-cli@7.2.3 actually load? Runtime test results

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

Runtimerequire("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✓ works✓ works

How to import webpack-cli

ES modules (import)

import webpackCli from "webpack-cli";

Named imports from a CommonJS package only work when Node.js can statically detect them. If a named import fails, use the default import and destructure.

CommonJS (require)

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

VersionsFormatFirst published
3.0.4 – 7.2.3CommonJSJun 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 everywhere. 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 on Sep 9, 2026.

Does webpack-cli ship TypeScript types?

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

Links

Other commonjs packages

Similar popularity