I am getting this error from ESLint:
JavaScript
x
2
1
error Parsing error: The keyword 'const' is reserved
2
from this code:
JavaScript
1
4
1
const express = require('express');
2
const app = express();
3
const _ = require('underscore');
4
I’ve tried removing node_modules
and reinstalling all npm packages (as suggested here), but to no avail.
Advertisement
Answer
ESLint defaults to ES5 syntax-checking.
You’ll want to override to the latest well-supported version of JavaScript.
Try adding a .eslintrc.json
file to your project. Inside it:
JavaScript
1
10
10
1
{
2
"parserOptions": {
3
"ecmaVersion": "latest"
4
},
5
6
"env": {
7
"es6": true
8
}
9
}
10
Hopefully this helps.
EDIT: I also found this example .eslintrc.json
which might help.