Matías Baldanza

ESLint - error Parsing error: The keyword const is reserved

Problem

After installing ESLint (or its config, StandardJS) in a NodeJS project, I got this error from ESLint:

error Parsing error: The keyword 'const' is reserved

from this line of code:

const express = require("express");

Solution

This happens because ESLint defaults to ES5 syntax-checking. To fix this, we need to override the default so ESLint uses ES6 syntax-checking.

Add a file .eslintrc.json to the root of the project with this content:

{
  "parserOptions": {
    "ecmaVersion": "latest"
  },

  "env": {
    "es6": true
  }
}

Source: StackOverflow