canirequire › CommonJS › 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.
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.
| 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 | ✓ 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).
| 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 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
- debug 4.4.3CommonJS
- semver 7.8.5CommonJS
- ms 2.1.3CommonJS
- picomatch 4.0.7CommonJS
- ajv 8.20.0CommonJS
- source-map 0.8.0CommonJS
- react-is 19.2.8CommonJS
- readable-stream 4.7.0CommonJS
Similar popularity
- @nestjs/common 12.0.1ESM-only
- cookie-parser 1.4.7CommonJS
- sinon 22.1.0Dual
- history 5.3.0CommonJS
- eslint-plugin-jest 29.16.6CommonJS
- isomorphic-fetch 3.0.0CommonJS
- stylelint 17.15.0ESM-only
- js-beautify 2.0.3CommonJS