【问题标题】:jshint javascript error - Expected ')' to match '{' from line n and instead saw 'response'. (E020)jshint javascript 错误 - 预期 ')' 与第 n 行中的 '{' 匹配,而是看到了 'response'。 (E020)
【发布时间】:2018-08-16 10:06:48
【问题描述】:

我正在关注Build a JavaScript Single Page App Without a Framework 的 SPA 教程

我的 server.js 文件中有以下代码,但它给出了错误:

const get = async (url) => {
  const response = await api.get(url);
  const { data } = response;
  if (data.success) {
    return data;
  }
  throw new Error(data.error.type);
};

我得到的错误是:

[jshint] "Expected ')' 匹配第 15 行中的 '{' 而看到的是 'response'。(E020)

我遇到的另一个错误(在同一行)是:

[jshint] "需要一个标识符,但看到的是 '='。(E030)

在我尝试过的文件顶部:

/*jshint esversion: 6 */

"ecmaVersion: 8";

那么这里有什么问题?我搜索了错误,发现SO: JS: How to fix “Expected ')' to match '(' from line 4 and instead saw '='.” JSLint error

这并没有真正帮助......

那么我可以在我的项目或代码中做些什么来解决这个问题?

【问题讨论】:

  • 看起来不支持 async 和 awaut .. 你需要一个 pollyfil 什么的
  • @ArupRakshit:我已经用npm install polyfill 安装了polyfill - 但没有运气......我也需要它吗?

标签: javascript nodes jshint fixer.io


【解决方案1】:

尝试将以下内容添加到工作场所设置设置

{
  "jshint.options": {
    "esversion": 6
  }
}

【讨论】:

    猜你喜欢
    • 2014-06-04
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 1970-01-01
    • 2014-04-24
    • 2013-05-12
    • 2016-10-14
    • 2011-09-13
    相关资源
    最近更新 更多