目录
- 出错现象
- 出错原因
- 解决方案
出错现象
这个报错在环境中安装了gulp-eslint
,eslint
并初始化之后,在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
解决方案
- 将
eslint-config-standard
版本进行降级为^14.1.1
,npm i eslint-config-standard@14.1.1 eslint-plugin-standard -D
- 删除
.eslintrc.js
里面的env
中的es2021
属性
it works~
网友评论