eslint-import-resolver-babel-module
raw JSON → 5.3.2 verified Sat Apr 25 auth: no javascript
A resolver for eslint-plugin-import that uses babel-plugin-module-resolver's alias configuration to resolve module paths. Version 5.3.2 is the current stable release, compatible with @babel/core ^7.0.0-0 and babel-plugin-module-resolver ^3.0.0 || ^4.0.0 || ^5.0.0. It allows ESLint to understand custom module aliases defined in Babel config, preventing false positive import/no-unresolved errors. Unlike eslint-import-resolver-alias or eslint-import-resolver-webpack, it integrates directly with Babel's module resolution, making it ideal for projects using babel-plugin-module-resolver. The package is actively maintained, with updates tracking eslint-plugin-import and babel-plugin-module-resolver releases.
Common errors
error Error: Cannot find module 'babel-plugin-module-resolver' ↓
cause Missing peer dependency.
fix
Run: npm install --save-dev babel-plugin-module-resolver
error Unable to resolve path to module '@components/Button' (eslintimport/no-unresolved) ↓
cause Babel alias not recognized by ESLint.
fix
Ensure the resolver is configured correctly in .eslintrc: "import/resolver": { "babel-module": {} } and that the alias is defined in Babel config.
error ESLint: 'import/resolver' setting must be an object ↓
cause Using string value instead of object.
fix
Change to: {"settings": {"import/resolver": {"babel-module": {}}}}
Warnings
breaking Version 5.x requires babel-plugin-module-resolver ^3.0.0 || ^4.0.0 || ^5.0.0. Older versions may not be compatible. ↓
fix Update babel-plugin-module-resolver to ^3.0.0, ^4.0.0, or ^5.0.0.
breaking Resolves only for Babel projects; if Babel config is missing, ESLint import resolution fails. ↓
fix Ensure @babel/core and babel-plugin-module-resolver are installed and configured in your project.
gotcha The resolver reads Babel configuration from the project root (babel.config.js, .babelrc, etc.). Nested configs may be ignored. ↓
fix Make sure your Babel config is in the root directory or use a project-level babel.config.js.
deprecated The option 'allowExistingDirectories' is experimental. It may be removed in future versions. ↓
fix If you rely on this feature, check changelog before upgrading.
Install
npm install eslint-import-resolver-babel-module yarn add eslint-import-resolver-babel-module pnpm add eslint-import-resolver-babel-module Imports
- default (resolve function) wrong
import { resolve } from 'eslint-import-resolver-babel-module'correctmodule.exports = { interfaceVersion: 2, resolve: (source, file, config) => { ... } } - (ESLint config import) wrong
{"settings": {"import/resolver": "babel-module"}}correct{"settings": {"import/resolver": {"babel-module": {}}}} - (TypeScript types) wrong
import { Resolver } from 'eslint-import-resolver-babel-module'correct// No TypeScript types provided; use @types/eslint-plugin-import if needed
Quickstart
// Install dependencies
npm install --save-dev eslint eslint-plugin-import eslint-import-resolver-babel-module @babel/core babel-plugin-module-resolver
// Configure .babelrc with aliases
{
"plugins": [
["module-resolver", {
"root": ["./src"],
"alias": {
"@components": "./src/components",
"@utils": "./src/utils"
}
}]
]
}
// Configure .eslintrc
{
"settings": {
"import/resolver": {
"babel-module": {}
}
}
}