首页 > 解决方案 > 模块解析失败:运行弹出后出现意外令牌

问题描述

希望有一个快速的解决方案。我刚刚在 typescript 内置的 React 应用程序上进行了弹出,以查看是否可以解决不同的问题。在尝试编译时,我现在收到此错误:

Module parse failed: Unexpected token (27:19)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|     }).catch(e => {
|       // remove sensitive fields
>       if (e.config?.data) delete e.config.data;
|       if (e.response?.config?.data) delete e.response.config.data;
|       super.analyticsHandler.error(`POST ${url} failed`, e);

我的猜测是delete导致问题的部分,但我不是 100%。也许我错过了一个 babel 插件?该项目在弹出之前正在编译。

如果您需要查看代码/配置的任何特定部分,请告诉我。

谢谢

编辑:这是 package.json 中的 babel 部分:

  "babel": {
    "plugins":
    [
        "@babel/plugin-proposal-nullish-coalescing-operator",
        "@babel/plugin-proposal-optional-chaining",
        [
            "@babel/plugin-proposal-decorators",
            {
                "legacy": true
            }
        ],
        "babel-plugin-transform-typescript-metadata"
    ],
    "presets": [
      "@babel/preset-env",
      "@babel/preset-react",
      "@babel/preset-typescript"
    ]
  }

标签: reactjstypescriptbabeljs

解决方案


推荐阅读