canirequire › CommonJS › @nomiclabs/hardhat-ethers
Is @nomiclabs/hardhat-ethers ESM-only? Can you require() it?
Hardhat plugin for ethers
Last verified Sep 9, 2026 against @nomiclabs/hardhat-ethers@2.2.3. JSON
CommonJS CommonJS — require() works on every Node.js version
@nomiclabs/hardhat-ethers ships CommonJS only. require("@nomiclabs/hardhat-ethers") works everywhere. import "@nomiclabs/hardhat-ethers" 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 @nomiclabs/hardhat-ethers@2.2.3 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("@nomiclabs/hardhat-ethers") from a CommonJS file and import "@nomiclabs/hardhat-ethers" from an ES module.
| Runtime | require("@nomiclabs/hardhat-ethers") | import "@nomiclabs/hardhat-ethers" |
|---|---|---|
| Node.js 18 | ✗ failsHardhatError | ✗ failsHardhatError |
| Node.js 20 | ✗ failsHardhatError | ✗ failsHardhatError |
| Node.js 22 | ✗ failsHardhatError | ✗ failsHardhatError |
| Node.js 24 | ✗ failsHardhatError | ✗ failsHardhatError |
| Node.js 26 | ✗ failsHardhatError | ✗ failsHardhatError |
| Bun 1.4 | ✗ failsHardhatError | ✗ failsHardhatError |
A failing require() on a CommonJS package usually means the package needs a browser/DOM global, a peer dependency, or a native binary that is not available in a bare Node.js process.
How to import @nomiclabs/hardhat-ethers
ES modules (import)
import hardhatEthers from "@nomiclabs/hardhat-ethers";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 hardhatEthers = require("@nomiclabs/hardhat-ethers");Module format by version
Derived from the type, main and exports fields of every stable release on npm (14 versions; the newest 14 shown).
| Versions | Format | First published |
|---|---|---|
| 1.0.0 – 2.2.3 | CommonJS | Oct 22, 2020 |
Frequently asked
Is @nomiclabs/hardhat-ethers ESM-only?
@nomiclabs/hardhat-ethers@2.2.3 is a CommonJS package. @nomiclabs/hardhat-ethers ships CommonJS only. require("@nomiclabs/hardhat-ethers") works everywhere. import "@nomiclabs/hardhat-ethers" 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 @nomiclabs/hardhat-ethers with ES module syntax?
Yes. import hardhatEthers from "@nomiclabs/hardhat-ethers" 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 @nomiclabs/hardhat-ethers work in Bun?
Importing @nomiclabs/hardhat-ethers failed in Bun 1.4 on Sep 9, 2026: HardhatError: HH5: HardhatContext is not created.
Does @nomiclabs/hardhat-ethers ship TypeScript types?
Yes. @nomiclabs/hardhat-ethers 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
- @release-it/conventional-changelog 12.0.0ESM-only
- @vue/eslint-config-standard 9.0.1ESM-only
- @storybook/addon-info 5.3.21CommonJS
- @vue/cli-plugin-unit-jest 5.0.9CommonJS
- @vitest/coverage-c8 0.33.0ESM-only