{"id":19678,"library":"eslint-module-utils","title":"eslint-module-utils","description":"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.","status":"active","version":"2.12.1","language":"javascript","source_language":"en","source_url":"https://github.com/import-js/eslint-plugin-import","tags":["javascript","eslint-plugin-import","eslint","modules","esmodules"],"install":[{"cmd":"npm install eslint-module-utils","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-module-utils","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-module-utils","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"debug is used for debugging output","package":"debug","optional":false},{"reason":"doctrine is used for parsing JSDoc annotations","package":"doctrine","optional":false},{"reason":"resolve is used for module resolution","package":"resolve","optional":false}],"imports":[{"note":"CommonJS require also works but destructuring is preferred.","wrong":"const ModuleCache = require('eslint-module-utils').ModuleCache","symbol":"ModuleCache","correct":"import { ModuleCache } from 'eslint-module-utils'"},{"note":"parse is a named export, not a default export. Avoid deep path imports.","wrong":"import parse from 'eslint-module-utils/parse'","symbol":"parse","correct":"import { parse } from 'eslint-module-utils'"},{"note":"Both ESM and CJS are supported. Ensure your ESLint plugin uses the correct dialect.","wrong":"var resolve = require('eslint-module-utils').resolve;","symbol":"resolve","correct":"import { resolve } from 'eslint-module-utils'"},{"note":"ModuleResolver is a named export, not default.","wrong":"import ModuleResolver from 'eslint-module-utils'","symbol":"ModuleResolver","correct":"import { ModuleResolver } from 'eslint-module-utils'"}],"quickstart":{"code":"import { ModuleCache } from 'eslint-module-utils';\nconst cache = new ModuleCache();\n// Use the cache to store and retrieve module resolution results\ncache.set('fs', { path: '/usr/lib/node_modules/fs' });\nconst result = cache.get('fs');\nconsole.log(result?.path); // '/usr/lib/node_modules/fs'","lang":"typescript","description":"Creates a ModuleCache instance, sets a resolved path for module 'fs', and retrieves it."},"warnings":[{"fix":"Pass an options object to the ModuleCache constructor, e.g., new ModuleCache({ cache: true }).","message":"ModuleCache constructor now requires options object in v3+","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Migrate to parseForESLint from @typescript-eslint/parser if using TypeScript.","message":"parse function is deprecated in v2.12.1, use parseForESLint from @typescript-eslint/parser instead","severity":"deprecated","affected_versions":">=2.10.0"},{"fix":"Use the enhanced-resolve package or rely on eslint-plugin-import's resolver for modern resolution.","message":"resolve does not support all Node.js resolution algorithms (e.g., exports map)","severity":"gotcha","affected_versions":"<=2.12.1"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install eslint-module-utils --save-dev","cause":"Missing dependency in package.json","error":"Cannot find module 'eslint-module-utils'"},{"fix":"npm install doctrine --save-dev","cause":"Peer dependency doctrine not installed","error":"Uncaught Error: Cannot find module 'doctrine'"},{"fix":"Use correct import: import { ModuleCache } from 'eslint-module-utils'","cause":"Incorrect import: using default import when ModuleCache is a named export","error":"TypeError: ModuleCache is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}