Registry / testing / eslint-module-utils

eslint-module-utils

JSON →
library2.12.1jsnpmunverified

eslint-module-utils (v2.12.1) provides core utilities for eslint-plugin-import and other module-related ESLint plugins. It includes helpers for parsing module resolution, resolving module paths, and managing module caches. Released under the MIT license, it supports Node >=4 and is maintained as part of the eslint-plugin-import ecosystem. Key differentiators: it is the foundational utility package powering eslint-plugin-import's module resolution, cache, and parsing features, and is used by plugins like eslint-plugin-import, eslint-plugin-node, and eslint-plugin-import-access.

npm install eslint-module-utils
INSTALL
IMPORT
SIG · ESLINT-MODULE-UTIL
E
eslint-module-utils
testingjavascriptv2.12.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ModuleCache
✓ import { ModuleCache } from 'eslint-module-utils'
✗ const ModuleCache = require('eslint-module-utils').ModuleCache
CommonJS require also works but destructuring is preferred.
parse
✓ import { parse } from 'eslint-module-utils'
✗ import parse from 'eslint-module-utils/parse'
parse is a named export, not a default export. Avoid deep path imports.
resolve
✓ import { resolve } from 'eslint-module-utils'
✗ var resolve = require('eslint-module-utils').resolve;
Both ESM and CJS are supported. Ensure your ESLint plugin uses the correct dialect.
ModuleResolver
✓ import { ModuleResolver } from 'eslint-module-utils'
✗ import ModuleResolver from 'eslint-module-utils'
ModuleResolver is a named export, not default.

Creates a ModuleCache instance, sets a resolved path for module 'fs', and retrieves it.

import { ModuleCache } from 'eslint-module-utils'; const cache = new ModuleCache(); // Use the cache to store and retrieve module resolution results cache.set('fs', { path: '/usr/lib/node_modules/fs' }); const result = cache.get('fs'); console.log(result?.path); // '/usr/lib/node_modules/fs'
Debug
Known issues
breakingModuleCache constructor now requires options object in v3+
fix
Pass an options object to the ModuleCache constructor, e.g., new ModuleCache({ cache: true }).
affects: >=3.0.0
deprecatedparse function is deprecated in v2.12.1, use parseForESLint from @typescript-eslint/parser instead
fix
Migrate to parseForESLint from @typescript-eslint/parser if using TypeScript.
affects: >=2.10.0
gotcharesolve does not support all Node.js resolution algorithms (e.g., exports map)
fix
Use the enhanced-resolve package or rely on eslint-plugin-import's resolver for modern resolution.
affects: <=2.12.1
Errors
Common errors & fixes
Cannot find module 'eslint-module-utils'
Missing dependency in package.json
fix
npm install eslint-module-utils --save-dev
Uncaught Error: Cannot find module 'doctrine'
Peer dependency doctrine not installed
fix
npm install doctrine --save-dev
TypeError: ModuleCache is not a constructor
Incorrect import: using default import when ModuleCache is a named export
fix
Use correct import: import { ModuleCache } from 'eslint-module-utils'
Upgrade
Version history
2.12.1latest on npm
Audit
Dependencies
debugrequireddebug is used for debugging output
doctrinerequireddoctrine is used for parsing JSDoc annotations
resolverequiredresolve is used for module resolution
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-module-utils — npm install eslint-module-utils · libregistry