首页 > 解决方案 > 如何解决 React 组件的 YARN 编译错误?

问题描述

我开始在 React Web 应用程序的世界中构建自己的方式,因为我正在关注此处提供的 Carbon Design System 教程:https ://www.carbondesignsystem.com/developing/react-tutorial/step-1

因为当我开始根据页面的步骤添加路由时,我发现自己陷入了以下无法编译的错误:

    Failed to compile.

./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js
TypeError: [BABEL] /home/hvg1928/carbon-tutorial/node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js: api.assumption is not a function (While processing: "/home/hvg1928/carbon-tutorial/node_modules/babel-preset-react-app/dependencies.js$0$18")
    at Generator.next (<anonymous>)
    at Generator.next (<anonymous>)

据我了解,正在调用 React Refresh 插件中的 api.assumption ,我没有在 package.json 文件的依赖项中看到它:

  "dependencies": {
    "@carbon/icons-react": "10.22.0",
    "caniuse-lite": "^1.0.30001258",
    "carbon-components": "10.25.0",
    "carbon-components-react": "7.25.0",
    "carbon-icons": "7.0.7",
    "enzyme": "3.11.0",
    "enzyme-adapter-react-16": "1.15.5",
    "react": "16.10.0",
    "react-dom": "16.10.0",
    "react-router-dom": "5.0.0",
    "react-scripts": "4.0.1"
  },

基于此,我应该从哪里开始寻找解决此编译错误的问题?是否有一系列步骤可用于解决此类编译错误?

标签: reactjscarbon-design-system

解决方案


推荐阅读