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. Markdown · JSON
CommonJS CommonJS on paper — require() failed in our runtime test
@nomiclabs/hardhat-ethers declares a CommonJS entry only, but require("@nomiclabs/hardhat-ethers") failed on every Node.js version in our probe: HardhatError: HH5: HardhatContext is not created. import "@nomiclabs/hardhat-ethers" resolves to the same file, so it fails the same way. That usually means a missing peer dependency, a browser-only global, or a package that is not meant to be loaded directly; see the runtime table below.
What to do
- require("@nomiclabs/hardhat-ethers") failed in our probe on every Node.js version (HardhatError: HH5: HardhatContext is not created); check the package README for peer dependencies or setup before relying on it.
- From ES modules use the default import: import hardhatEthers from "@nomiclabs/hardhat-ethers"; then destructure. Named imports only work when Node.js can statically detect the exports.
- TypeScript: types are bundled; install nothing extra.
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.0 | ✗ 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)
// require("@nomiclabs/hardhat-ethers") failed in our probe on every Node.js version we test (HardhatError: HH5: HardhatContext is not created); see the runtime table.
const hardhatEthers = require("@nomiclabs/hardhat-ethers");Module format by version
Derived from the type, main and exports fields of every stable release on npm, corrected where a runtime test of that version contradicted them (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 declares a CommonJS entry, but require() fails at runtime. @nomiclabs/hardhat-ethers declares a CommonJS entry only, but require("@nomiclabs/hardhat-ethers") failed on every Node.js version in our probe: HardhatError: HH5: HardhatContext is not created. import "@nomiclabs/hardhat-ethers" resolves to the same file, so it fails the same way. That usually means a missing peer dependency, a browser-only global, or a package that is not meant to be loaded directly; see the runtime table below.
Can I require @nomiclabs/hardhat-ethers?
Not in practice. @nomiclabs/hardhat-ethers declares a CommonJS entry, but require("@nomiclabs/hardhat-ethers") failed on every Node.js version in our probe: HardhatError: HH5: HardhatContext is not created. Check the package README for peer dependencies or setup before relying on it.
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.0 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
- element-ui 2.15.14CommonJS
- gulp-load-plugins 2.0.8CommonJS
- @vue/eslint-config-standard 9.0.1ESM-only
- rollup-plugin-delete 3.0.2ESM-only
- babel-plugin-transform-vue-jsx 3.7.0CommonJS
- @vitest/coverage-c8 0.33.0ESM-only
- run-sequence 2.2.1CommonJS
- rollup-plugin-uglify 6.0.4CommonJS