canirequire

canirequireCommonJS › @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.

Latest
2.2.3 (Apr 10, 2023)
Module format
CommonJS
Last CommonJS version
2.2.3
TypeScript types
Bundled
Node engines
not declared
License
MIT

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.

Runtimerequire("@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).

VersionsFormatFirst published
1.0.0 – 2.2.3CommonJSOct 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

Similar popularity