canirequire

canirequire › ESM-only › eslint-plugin-mocha

Is eslint-plugin-mocha ESM-only? Can you require() it?

Eslint rules for mocha.

Last verified Sep 9, 2026 against eslint-plugin-mocha@12.0.2. Markdown · JSON

ESM-only ESM-only since 11.0.0 — last CommonJS version is 10.5.0

eslint-plugin-mocha dropped its CommonJS build in 11.0.0 (April 2025). The last version with a plain require()-able CommonJS entry is 10.5.0, published Jul 29, 2024; it declares support for Node.js >=14.0.0.

require("eslint-plugin-mocha") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it. Node.js 18 has no require(esm), and eslint-plugin-mocha@12.0.2 declares Node.js >=22.0.0, so 18 is outside its supported range anyway.

eslint-plugin-mocha@12.0.2 declares engines ">=22.0.0", so Node.js 18, 20 are outside its supported range regardless of module format.

What to do

  1. require("eslint-plugin-mocha") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it.
  2. From a CommonJS file, use a dynamic import inside an async function: const eslintPluginMocha = await import("eslint-plugin-mocha"). That works on every Node.js version the package supports (>=22.0.0).
  3. If you need a synchronous require() or run Node.js 18: npm install eslint-plugin-mocha@10.5.0, the last CommonJS release (published Jul 29, 2024); it declares Node.js >=14.0.0.
  4. eslint-plugin-mocha@12.0.2 declares engines ">=22.0.0", so Node.js 18, 20 are unsupported regardless: upgrade Node.js or pin an older release.
  5. TypeScript: types are bundled; install nothing extra.
Latest
12.0.2 (Aug 4, 2026)
Module format
ESM-only
Last CommonJS version
10.5.0
ESM-only since
11.0.0 (Apr 26, 2025)
TypeScript types
Bundled
Node engines
>=22.0.0
Weekly downloads
1.6M
License
MIT

Does eslint-plugin-mocha@12.0.2 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("eslint-plugin-mocha") from a CommonJS file and import "eslint-plugin-mocha" from an ES module.

Runtimerequire("eslint-plugin-mocha")import "eslint-plugin-mocha"
Node.js 18✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✓ works
Node.js 20✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✓ works
Node.js 22✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✓ works
Node.js 24✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✓ works
Node.js 26✗ failsERR_PACKAGE_PATH_NOT_EXPORTED✓ works
Bun 1.4.0✗ failsError✓ works

How to import eslint-plugin-mocha

ES modules (import)

import * as eslintPluginMocha from "eslint-plugin-mocha";

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS (require)

// require("eslint-plugin-mocha") failed in our probe on Node.js 22.12+ and newer as well (ERR_PACKAGE_PATH_NOT_EXPORTED); see the runtime table.

// Any Node.js version the package supports (>=22.0.0), from an async function:
async function main() {
  const eslintPluginMocha = await import("eslint-plugin-mocha");
}

// Or pin the last CommonJS release (declares Node.js >=14.0.0):
// npm install eslint-plugin-mocha@10.5.0

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 (70 versions; the newest 60 shown).

VersionsFormatFirst published
11.0.0 – 12.0.2ESM-onlyApr 26, 2025
1.1.0 – 10.5.0CommonJSNov 13, 2015

Frequently asked

Is eslint-plugin-mocha ESM-only?

eslint-plugin-mocha@12.0.2 is ESM-only. eslint-plugin-mocha dropped its CommonJS build in 11.0.0 (April 2025). The last version with a plain require()-able CommonJS entry is 10.5.0, published Jul 29, 2024; it declares support for Node.js >=14.0.0.

Which version of eslint-plugin-mocha still supports CommonJS / require()?

10.5.0 is the last version of eslint-plugin-mocha with a CommonJS build; it declares Node.js >=14.0.0. Install it with "npm install eslint-plugin-mocha@10.5.0". Every version from 11.0.0 on is ESM-only.

How do I use eslint-plugin-mocha from a CommonJS file?

From a CommonJS file, use a dynamic import inside an async function: const eslintPluginMocha = await import("eslint-plugin-mocha"). That works on every Node.js version the package supports (>=22.0.0). require("eslint-plugin-mocha") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it. Alternatively pin eslint-plugin-mocha@10.5.0 (declares Node.js >=14.0.0).

Does eslint-plugin-mocha work in Bun?

Yes. import "eslint-plugin-mocha" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

Does eslint-plugin-mocha ship TypeScript types?

Yes. eslint-plugin-mocha bundles its own type declarations; no @types package is needed.

Links

Other esm-only packages

Similar popularity