eslint-config-standard: Environment key "es2021" is unknown

version: 15.0.0, didnt have error in previous version

Error: .eslintrc » eslint-config-standard: Environment key “es2021” is unknown

.eslintrc { "extends": "standard", "rules": { "padded-blocks": ["error", "always"], "space-before-function-paren": ["error", "never"], "semi": ["error", "always"], "eol-last": ["error", "never"], "no-trailing-spaces": ["error", { "skipBlankLines": true, "ignoreComments": true }], "space-infix-ops": 0, "one-var": ["error", { "initialized": "consecutive" }], }, "globals": { "jQuery": true, "$": true } }

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23 (6 by maintainers)

Commits related to this issue

Most upvoted comments

@bonesoul Are you sure that’s the ESLint that is used then?

Do you see this error on the command line or in eg. Visual Studio Code?

If on command line:

  1. Have you ensured that you are running the local eslint and not a globally installed one?
    1. If you run npx eslint --version – then it shows v7.11.0?
    2. If you run eslint --version – does it run? If so, does it also show v7.11.0?

If in Visual Studio Code or similar:

  1. Which extension are you using?
  2. Which version of that extension?
  3. Which version of Visual Studio Code?

same here.

You need to update your ESLint then, es2021 was introduced in ESLint version 7.8.0: https://github.com/eslint/eslint/releases/tag/v7.8.0

Also, eslint-config-standard version 15.0.0 states that it requires at least ESLint 7.11.0, so you should be seeing some kind of warning about having wrong peer dependencies: https://github.com/standard/eslint-config-standard/blob/6cd5bd5371189e9c8bda05992644de6e589a7a53/package.json#L51

A friendly suggestion to avoid this in the future:

If you use the install-peerdeps CLI tool to install a package like this, which has many peer dependencies, then it will automatically install the correct peer dependencies for you.

I have run into this problem recently.

ESLint error log

[Error - 12:07:00 PM] ESLint stack trace:
[Error - 12:07:00 PM] Error: .eslintrc.cjs » @chatie/eslint-config » eslint-config-standard:
	Environment key "es2021" is unknown

    at /Users/huan/git/huan/ducks/node_modules/eslint/lib/shared/config-validator.js:169:19
    at Array.forEach (<anonymous>)
    at validateEnvironment (/Users/huan/git/huan/ducks/node_modules/eslint/lib/shared/config-validator.js:163:30)
    at validateConfigArray (/Users/huan/git/huan/ducks/node_modules/eslint/lib/shared/config-validator.js:334:9)
    at CascadingConfigArrayFactory._finalizeConfigArray (/Users/huan/git/huan/ducks/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:417:13)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/huan/git/huan/ducks/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:271:21)
    at CLIEngine.isPathIgnored (/Users/huan/git/huan/ducks/node_modules/eslint/lib/cli-engine/cli-engine.js:951:18)
    at CLIEngine.executeOnText (/Users/huan/git/huan/ducks/node_modules/eslint/lib/cli-engine/cli-engine.js:868:38)
    at _e.lintText (/Users/huan/.vscode/extensions/dbaeumer.vscode-eslint-2.1.25/server/out/eslintServer.js:1:177327)
    at /Users/huan/.vscode/extensions/dbaeumer.vscode-eslint-2.1.25/server/out/eslintServer.js:1:171074

NPM versions

ducks@0.11.1 /Users/huan/git/huan/ducks
└─┬ @chatie/eslint-config@0.14.1
  ├─┬ @typescript-eslint/eslint-plugin-tslint@4.31.1
  │ ├─┬ @typescript-eslint/experimental-utils@4.31.1
  │ │ ├─┬ eslint-utils@3.0.0
  │ │ │ └── eslint@7.32.0 deduped
  │ │ └── eslint@7.32.0 deduped
  │ └── eslint@7.32.0 deduped
  ├─┬ @typescript-eslint/eslint-plugin@4.31.1
  │ └── eslint@7.32.0 deduped
  ├─┬ @typescript-eslint/parser@4.31.1
  │ └── eslint@7.32.0 deduped
  ├─┬ babel-eslint@10.1.0
  │ └── eslint@7.32.0 deduped
  ├─┬ eslint-config-standard@16.0.3
  │ └── eslint@7.32.0 deduped
  ├─┬ eslint-plugin-import@2.24.2
  │ └── eslint@7.32.0 deduped
  ├─┬ eslint-plugin-node@11.1.0
  │ ├─┬ eslint-plugin-es@3.0.1
  │ │ └── eslint@7.32.0 deduped
  │ └── eslint@7.32.0 deduped
  ├─┬ eslint-plugin-promise@5.1.0
  │ └── eslint@7.32.0 deduped
  ├─┬ eslint-plugin-standard@5.0.0
  │ └── eslint@7.32.0 deduped
  └── eslint@7.32.0

✔ ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:06 $ npx eslint --version
v7.32.0
✔ ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:09 $ npm ls eslint-config-standard
ducks@0.11.1 /Users/huan/git/huan/ducks
└─┬ @chatie/eslint-config@0.14.1
  └── eslint-config-standard@16.0.3

✔ ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:09 $ eslint --version
bash: eslint: command not found
✘-127 ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:09 $ esli^C
✘-INT ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:09 $ npx eslint --version
v7.32.0
✔ ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:09 $ eslint --version
bash: eslint: command not found

Reproducible repo

https://github.com/huan/ducks

BTW: the above error only shows in vscode, but I can run eslint without any problem in command line.

I ran into this as well. Reason was, I had an outdated eslint installed globally (7.6.0) that was picked up by neovim instead of the project wide dependency @ 7.14.0. A npm i -g eslint did it for me.

i’m already using eslint 7.11.0;

"eslint": "7.11.0",

same here.

This is maybe a longshot, but for future folks: I am working in a monorepo with nested packages, where the base repo had the correct version of eslint, but a child repo had its own version of eslint that was older. So if you have nested repos, double-check (and make sure npx eslint --version says what you think it should!)

For future reference, in my case, it turns out prettier-standard is the culprit. It is way behind standard releases nowadays.

I still ran into this, and I’m using eslint@7.32.0, both locally and globally are the same.

I’ve degraded eslint-config-standard to 14.0.0, it works for me.