【问题标题】:Missing class properties transform in headers.jsheaders.js 中缺少类属性转换
【发布时间】:2023-01-19 23:41:52
【问题描述】:

如何解决这个问题?

Failed to compile.

C:/Users/nick_/VSCodeProjects/nft-school-examples/end-to-end/node_modules/hardhat/node_modules/undici/lib/fetch/headers.js
SyntaxError: C:\Users\nick_\VSCodeProjects\nft-school-examples\end-to-end\node_modules\hardhat\node_modules\undici\lib\fetch\headers.js: Missing class properties tran
sform.
  67 | class HeadersList {
  68 |   /** @type {[string, string][]|null} */
> 69 |   cookies = null
     |   ^^^^^^^^^^^^^^
  70 |
  71 |   constructor (init) {
  72 |     if (init instanceof HeadersList) {
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'

我添加了babel.config.js,但还是一样

module.exports = {
    presets: ["@expo/next-adapter/babel"],
    overrides: [
      {
        test: "./node_modules/@expo/next-adapter/document.js",
        plugins: [["@babel/plugin-proposal-class-properties"]],
      },
    ],
  }

我的包.json

"devDependencies": {
    "@babel/plugin-proposal-class-properties": "^7.18.6",
    "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers",
    "ethers": "^5.7.2",
    "hardhat": "^2.12.6"
  },

【问题讨论】:

    标签: javascript babeljs babel-loader


    【解决方案1】:

    根据您的 babel 配置,您正在尝试为 @expo 模块中的某些文件应用插件:

    ...
     test: "./node_modules/@expo/next-adapter/document.js",
    ...
    

    但似乎你在不同的模块中有错误 -安全帽.

    尝试更改引发错误的模块的路径。

    [更新]

    //babel.config.js
    module.exports = {
        presets: ["@expo/next-adapter/babel"],
        overrides: [
          {
            test: "module where issue was thrown",
            plugins: [["@babel/plugin-proposal-class-properties"]],
          },
        ],
      }
    

    【讨论】:

    • 你的意思是更换测试路径?
    • @JohnJoe 是的。 prop test 中的路径定义了一个或多个文件以应用插件。
    • 但是在哪里可以找到这条线 test:"..."
    • @JohnJoe 在你的 babel 配置中(已经更新了答案)
    • test :"..." 替换为 node_modules/hardhat/node_modules/undici/lib/fetch/headers.js
    猜你喜欢
    • 1970-01-01
    • 2017-03-19
    • 1970-01-01
    • 2019-02-09
    • 2018-11-16
    • 2016-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多