# Is @nomiclabs/hardhat-ethers ESM-only? Can you require() it?

> @nomiclabs/hardhat-ethers@2.2.3 declares a CommonJS entry, but require() fails at runtime. CommonJS on paper — require() failed in our runtime test.

Hardhat plugin for ethers

Last verified Sep 9, 2026 against @nomiclabs/hardhat-ethers@2.2.3.

@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

1. 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.
2. 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.
3. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 2.2.3 (Apr 10, 2023)
- Module format: CommonJS
- Last CommonJS version: 2.2.3
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 99K
- License: MIT

## Runtime test results for @nomiclabs/hardhat-ethers@2.2.3

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 | fails (HardhatError) | fails (HardhatError) |
| Node.js 20 | fails (HardhatError) | fails (HardhatError) |
| Node.js 22 | fails (HardhatError) | fails (HardhatError) |
| Node.js 24 | fails (HardhatError) | fails (HardhatError) |
| Node.js 26 | fails (HardhatError) | fails (HardhatError) |
| Bun 1.4.0 | fails (HardhatError) | fails (HardhatError) |

## How to import @nomiclabs/hardhat-ethers

ES modules:

```js
import hardhatEthers from "@nomiclabs/hardhat-ethers";
```

CommonJS:

```js
// 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 (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

- [@nomiclabs/hardhat-ethers on npm](https://www.npmjs.com/package/@nomiclabs/hardhat-ethers)
- [Source repository](https://github.com/nomiclabs/hardhat)
- [HTML version](https://canirequire.com/package/@nomiclabs/hardhat-ethers/)
- [JSON version](https://canirequire.com/package/@nomiclabs/hardhat-ethers.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
