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
- 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.
- 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).
- 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.
- 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.
- TypeScript: types are bundled; install nothing extra.
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.
| Runtime | require("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.0Module 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).
| Versions | Format | First published |
|---|---|---|
| 11.0.0 – 12.0.2 | ESM-only | Apr 26, 2025 |
| 1.1.0 – 10.5.0 | CommonJS | Nov 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
- ansi-styles 7.0.0last CJS
5.2.0 - strip-ansi 7.2.0last CJS
6.0.1 - commander 15.0.0last CJS
14.0.3 - supports-color 11.0.0last CJS
8.1.1 - chalk 6.0.0last CJS
4.1.2 - string-width 8.2.2last CJS
4.2.3 - ansi-regex 6.3.0last CJS
5.0.1 - escape-string-regexp 5.0.0last CJS
4.0.0
Similar popularity
- karma-jasmine 5.1.0CommonJS
- babel-polyfill 6.26.0CommonJS
- babel-plugin-transform-es2015-modules-commonjs 6.26.2CommonJS
- @semantic-release/git 11.0.1ESM-only
- @babel/polyfill 7.12.1CommonJS
- async-validator 4.2.5CommonJS
- @ethersproject/networks 5.8.0CommonJS
- @storybook/addons 7.6.17Dual