{"id":19665,"library":"eslint-import-resolver-lerna","title":"eslint-import-resolver-lerna","description":"Resolver for eslint-plugin-import that enables module resolution in Lerna-based monorepos. Version 2.0.0 (latest, Nov 2020) is a rewrite to TypeScript with breaking changes from 1.x. It maps packages defined in Lerna's packages directories so that eslint-plugin-import can resolve cross-package imports, particularly needed when using compilation pipelines (Babel, TypeScript) that output to a different directory. Unlike the built-in Node resolver, this supports non-standard packages directories and helps avoid \"Unable to resolve path to module\" errors in monorepos.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"git://github.com/Dreamscapes/eslint-import-resolver-lerna","tags":["javascript","eslint-plugin-import","lerna","resolver"],"install":[{"cmd":"npm install eslint-import-resolver-lerna","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-import-resolver-lerna","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-import-resolver-lerna","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: the resolver is used by this plugin","package":"eslint-plugin-import","optional":false},{"reason":"optional: only needed if using Lerna for monorepo management","package":"lerna","optional":true}],"imports":[{"note":"ESM-only since v2; CJS require will not work with default export.","wrong":"const resolver = require('eslint-import-resolver-lerna')","symbol":"default","correct":"import resolver from 'eslint-import-resolver-lerna'"},{"note":"resolveSync is the named export for synchronous resolution; resolve does not exist.","wrong":"import { resolve } from 'eslint-import-resolver-lerna'","symbol":"resolveSync","correct":"import { resolveSync } from 'eslint-import-resolver-lerna'"},{"note":"resolve is a named export returning a promise (async). Not to be confused with resolveSync.","wrong":"import { resolve as syncResolve } from 'eslint-import-resolver-lerna'","symbol":"resolve","correct":"import { resolve } from 'eslint-import-resolver-lerna'"}],"quickstart":{"code":"// .eslintrc.js\nmodule.exports = {\n  settings: {\n    'import/resolver': {\n      'eslint-import-resolver-lerna': {\n        packages: __dirname + '/packages'\n      }\n    }\n  }\n};","lang":"javascript","description":"Configure eslint-plugin-import to use lerna resolver for packages directory."},"warnings":[{"fix":"Use import syntax; if you need CJS, stay on 1.x or use dynamic import.","message":"Version 2.0.0 drops CommonJS support; package is now ESM-only.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use named exports: import { resolve, resolveSync } from the package.","message":"The default export changed from a function to an object in v2.0.0.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always use absolute paths, e.g., path.resolve(__dirname, 'packages').","message":"The 'packages' option no longer accepts relative paths in some ESLint contexts.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Ensure every package subdirectory has a package.json with a valid 'name' field.","message":"The resolver expects package.json files in the packages subdirectories; missing ones cause silent failures.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always specify the 'packages' setting pointing to the packages directory.","message":"The resolver does not automatically detect Lerna's lerna.json; 'packages' option is mandatory.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Add the lerna resolver configuration in .eslintrc as shown in quickstart.","cause":"eslint-plugin-import cannot find the internal package without the resolver.","error":"Unable to resolve path to module './packages/foo'."},{"fix":"Install eslint-plugin-import as a dev dependency: npm i -D eslint-plugin-import","cause":"Missing or misconfigured peer dependency eslint-plugin-import.","error":"Error: Cannot find module 'eslint-import-resolver-lerna'"},{"fix":"Change to import syntax in an ESM context or downgrade to v1.","cause":"Using require() for v2 which is ESM-only.","error":"TypeError: resolver.create is not a function"},{"fix":"Ensure packages is a string path or array of absolute paths.","cause":"Invalid type passed to packages option.","error":"The \"packages\" option must be a string or array of strings."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}