美文网首页
Error: .eslintrc.js » eslint-con

Error: .eslintrc.js » eslint-con

作者: 顽皮的雪狐七七 | 来源:发表于2020-11-03 10:38 被阅读0次

    目录

    • 出错现象
    • 出错原因
    • 解决方案

    出错现象

    这个报错在环境中安装了gulp-eslinteslint并初始化之后,在gulp中使用的时候报的错误。

    Error: .eslintrc.js » eslint-config-standard:
            Environment key "es2021" is unknown
    
    alidator.js:169:19
        at Array.forEach (<anonymous>)
        at validateEnvironment (E:\professer\lagou\ESLint\csf-gulp-demo-master\node_modules\gulp-eslint\node_modules\eslint\lib\shared\config-validator.js:163:30)
        at validateConfigArray (E:\professer\lagou\ESLint\csf-gulp-demo-master\node_modules\gulp-eslint\node_modules\eslint\lib\shared\config-validator.js:334:9)
        at CascadingConfigArrayFactory._finalizeConfigArray (E:\professer\lagou\ESLint\csf-gulp-demo-master\node_modules\gulp-eslint\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js:417:13)
        at CascadingConfigArrayFactory.getConfigArrayForFile (E:\professer\lagou\ESLint\csf-gulp-demo-master\node_modules\gulp-eslint\node_modules\eslint\lib\cli-engine\cascading-config-array-factory.js:271:21)
        at CLIEngine.isPathIgnored (E:\professer\lagou\ESLint\csf-gulp-demo-master\node_modules\gulp-eslint\node_modules\eslint\lib\cli-engine\cli-engine.js:951:18)
        at Transform._transform (E:\professer\lagou\ESLint\csf-gulp-demo-master\node_modules\gulp-eslint\index.js:43:14)  
        at Transform._read (_stream_transform.js:191:10)
        at Transform._write (_stream_transform.js:179:12)
    

    出错原因

    是版本的问题,因为使用的gulp-eslint版本和eslint以及eslint-config-standard版本不兼容导致的错误

    之前的版本是

    • node -v —— v12.19.0
    • npm -v —— v6.14.8
    • gulp -v —— ^4.0.2
    • gulp-eslint -v—— ^6.0.0
    • eslint -v—— ^7.12.1
    • eslint-config-standard -v—— ^16.0.1

    解决方案

    1. eslint-config-standard版本进行降级为^14.1.1npm i eslint-config-standard@14.1.1 eslint-plugin-standard -D
    2. 删除.eslintrc.js里面的env中的es2021属性

    it works~

    相关文章

      网友评论

          本文标题:Error: .eslintrc.js » eslint-con

          本文链接:https://www.haomeiwen.com/subject/diomvktx.html