导入包时当前未启用对实验语法“jsx”的支持

问题描述

我目前正在构建我自己的 UI,我想在我正在处理的另一个项目中进行测试。当我单独测试 UI 时,一切正常,但是一旦我将包导入另一个,我就会收到以下错误

./node_modules/simagdo-ui/src/components/layout/Layout.js
SyntaxError: C:\Users\simag\IdeaProjects\crm-tool\crm-frontend\node_modules\simagdo-ui\src\components\layout\Layout.js: Support for the experimental Syntax 'jsx' isn't currently enabled (11:9):

   9 |
  10 |     return (
> 11 |         <div
     |         ^
  12 |             className="Layout-Row--Wrapper">
  13 |
  14 |             {children.map((column,index) => {

Add @babel/preset-react (https://git.io/JfeDR) to the 'presets' section of your Babel config to enable transformation.
If you want to leave it as-is,add @babel/plugin-Syntax-jsx (https://git.io/vb4yA) to the 'plugins' section to enable parsing.

我的 Package.json 如下所示:

{
  "name": "simagdo-ui","version": "0.2.4","private": false,"dependencies": {
    "axios": "^0.21.1","node-sass": "^5.0.0","prop-types": "^15.7.2","react": "^17.0.2","react-dom": "^17.0.2","react-scripts": "4.0.3","sass": "^1.32.11","web-vitals": "^1.1.1"
  },"scripts": {
    "start": "react-scripts start","build": "react-scripts build","test": "react-scripts test","eject": "react-scripts eject"
  },"browserslist": {
    "production": [
      ">0.2%","not dead","not op_mini all"
    ],"development": [
      "last 1 chrome version","last 1 firefox version","last 1 safari version"
    ]
  }
}

还有 .Babelrc:

{
  "presets": [
    "@babel/preset-env","@babel/preset-react"
  ],"plugins": [
    "@babel/plugin-transform-react-jsx"
  ]
}

我按照建议导入了@babel/plugin-Syntax-jsx,但没有成功。

您可以在此处找到代码https://github.com/simagdo/simagdo-ui 以及导致问题的组件:https://github.com/simagdo/simagdo-ui/blob/master/src/components/layout/Layout.js

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)