javascript - VSCode ESLint 异步函数不支持

标签 javascript node.js visual-studio-code eslint

我尝试在 VSCode 上配置 ESLint,但在使用 async/await 函数时收到此错误:

Async functions are not supported until Node.js 7.6.0. The configured version range is '>=6.0.0'. (node/no-unsupported-features/es-syntax)"

但这是我的 .eslintrc.json:

{
  "root": true,
  "extends": [
    "eslint:recommended",
    "plugin:node/recommended"
  ],
  "parserOptions": {
    "ecmaVersion": 2018
  },
  "env": {
    "node": true,
    "mocha": true
  }
}

我错过了什么吗?

最佳答案

添加

  "engines": {
    "node": ">=7.6.0"
  }

到模块的 package.json 文件应该可以解决这些错误。

来自https://github.com/mysticatea/eslint-plugin-node#readme ,

Note: It recommends a use of the "engines" field of package.json. The "engines" field is used by node/no-unsupported-features/* rules.

关于javascript - VSCode ESLint 异步函数不支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52047611/

相关文章:

javascript - JS 文本转数组

javascript - 为什么这个文本输入在 iOS 上不起作用?

javascript - WebStorm 错误 : expression statement is not assignment or call

node.js - Google Cloud 语音识别 grpc 版本与 VSCode Electron 版本不兼容

visual-studio-code - 使用 VSCode,如何比较 Gitlens 中文件的两个非连续提交

javascript - 如何使用 JSON 作为 contentType 制作 Kendo MVC Helpers 的 CRUD

javascript - Fullcalendar 显示每天的事件数

node.js - 为什么在 Node.js 中数组占用的内存比缓冲区少?

forms - 无法在 Node.js Express 中使用表单

visual-studio-code - 摆脱帮助窗口