eslint:error解析错误:保留关键字“const” [英] eslint: error Parsing error: The keyword 'const' is reserved

查看:1148
本文介绍了eslint:error解析错误:保留关键字“const”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从ESLint收到此错误:

I am getting this error from ESLint:

error  Parsing error: The keyword 'const' is reserved

来自此代码:

const express = require('express');
const app = express();
const _ = require('underscore');

我尝试删除 node_modules 并重新安装所有npm包(建议这里),但是没有有效。

I've tried removing node_modules and reinstalling all npm packages (as suggested here), but to no avail.

推荐答案

ESLint默认使用ES5语法检查。您需要覆盖最新的支持良好的JavaScript版本。

ESLint defaults to ES5 syntax-checking. You'll want to override to the latest well-supported version of JavaScript.

尝试添加 .eslintrc 文件到你的项目。内部:

Try adding a .eslintrc file to your project. Inside it:

{
    "parserOptions": {
        "ecmaVersion": 2017
    },

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

希望这会有所帮助。

编辑:我还找到了这个例子 .eslintrc 可能有所帮助。

I also found this example .eslintrc which might help.

这篇关于eslint:error解析错误:保留关键字“const”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆