Last modified: Jul 20, 2025 By Alexander Williams

Install Babel-ESLint in Node.js

Babel-ESLint allows you to lint modern JavaScript code. It works with ESLint to parse code using Babel's parser. This guide will show you how to install and configure it.

Prerequisites

Before installing babel-eslint, you need:

- Node.js installed on your system

- Basic knowledge of npm commands

- An existing Node.js project

If you haven't installed ESLint yet, check our guide on How to Install ESLint in Node.js first.

Install Babel-ESLint

First, install babel-eslint as a development dependency:


npm install babel-eslint --save-dev

This will add babel-eslint to your devDependencies in package.json.

Configure ESLint to Use Babel-ESLint

Create or modify your .eslintrc file to use babel-eslint as the parser:


{
  "parser": "babel-eslint",
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module"
  }
}

The parserOptions tell ESLint what JavaScript features to expect.

Example Configuration

Here's a complete example configuration:


{
  "parser": "babel-eslint",
  "env": {
    "browser": true,
    "node": true
  },
  "extends": "eslint:recommended",
  "rules": {
    "indent": ["error", 2],
    "quotes": ["error", "single"]
  }
}

This setup includes basic linting rules and environment settings.

Running ESLint with Babel-ESLint

Add a lint script to your package.json:


"scripts": {
  "lint": "eslint ."
}

Then run the linter:


npm run lint

This will check all JavaScript files in your project.

Troubleshooting

If you get errors, try these solutions:

1. Make sure all dependencies are installed

2. Check your .eslintrc configuration

3. Verify file paths in your project

For module-related errors, see our guide on Fix Error: Cannot Find Module in Node.js.

Alternative Parsers

Since babel-eslint is now deprecated, consider using:

- @babel/eslint-parser (official replacement)

- @typescript-eslint/parser for TypeScript

For more Node.js modules, check our guide on How to Install Express Module in Node.js.

Conclusion

Babel-ESLint helps lint modern JavaScript code in Node.js projects. While it's now deprecated, the same concepts apply to its replacement, @babel/eslint-parser. Proper linting improves code quality and catches errors early.

Remember to keep your dependencies updated and configure ESLint according to your project needs. Happy coding!