Last modified: Jun 26, 2025 By Alexander Williams

Fix Error: Cannot find module 'eslint-config-airbnb'

If you encounter the error Cannot find module 'eslint-config-airbnb', don't worry. This guide will help you resolve it quickly.

Why does this error occur?

The error happens when Node.js cannot locate the eslint-config-airbnb package in your project. This is common in projects using ESLint with Airbnb's style guide.

The main causes include:

  • Missing package installation
  • Incorrect dependency versions
  • Global vs local package conflicts

Solution 1: Install the required packages

First, install eslint-config-airbnb and its peer dependencies. Run this command:


npx install-peerdeps --dev eslint-config-airbnb

This command automatically installs all required dependencies. If you prefer manual installation:


npm install --save-dev eslint-config-airbnb eslint-plugin-import eslint-plugin-react eslint-plugin-jsx-a11y eslint

Solution 2: Verify package.json

Check your package.json file. Ensure the packages are listed under devDependencies:


"devDependencies": {
  "eslint": "^8.0.0",
  "eslint-config-airbnb": "^19.0.0",
  "eslint-plugin-import": "^2.25.0",
  "eslint-plugin-jsx-a11y": "^6.5.0",
  "eslint-plugin-react": "^7.28.0"
}

If you see similar errors like Cannot find module 'eslint', the same solutions apply.

Solution 3: Clear npm cache

Sometimes a corrupted cache causes module errors. Clear it with:


npm cache clean --force

Then reinstall your dependencies:


rm -rf node_modules package-lock.json
npm install

Solution 4: Check ESLint configuration

Verify your .eslintrc file extends the Airbnb config correctly:


{
  "extends": "airbnb",
  "rules": {
    // Your custom rules
  }
}

For TypeScript projects, use airbnb-typescript instead. Similar configuration issues can occur with other modules like babel-eslint.

Solution 5: Check Node.js and npm versions

Ensure you're using compatible versions. Run:


node -v
npm -v

Update if necessary. Some packages require newer versions of Node.js and npm.

Solution 6: Global vs local installation

Avoid global ESLint installations when working with project-specific configurations. Use local installations instead.

If you have ESLint installed globally, remove it:


npm uninstall -g eslint

Then install it locally in your project. Similar issues can occur with tools like nodemon.

Conclusion

The Cannot find module 'eslint-config-airbnb' error is common but easy to fix. The solutions include proper package installation, cache cleaning, and configuration checks.

Always ensure your development environment is properly set up. Check for version compatibility and use local installations for project-specific tools.

If you still face issues, check the official ESLint and Airbnb style guide documentation for the latest installation instructions.