Node.js 运行react应用程序时发现重复的自我道具

Node.js 运行react应用程序时发现重复的自我道具,node.js,reactjs,npm,dependencies,babeljs,Node.js,Reactjs,Npm,Dependencies,Babeljs,在react应用程序中运行npm run时,我遇到此错误: Syntax Error index.js: Duplicate __self prop found. You are most likely using the deprecated transform-react-jsx-self Babel plugin. Both __source and __self are automatically set when using the automatic runtime. Please

在react应用程序中运行npm run时,我遇到此错误:

Syntax Error index.js: Duplicate __self prop found. You are most likely using the deprecated transform-react-jsx-self Babel 
plugin. Both __source and __self are automatically set when using the automatic runtime. Please remove transform-react-jsx-source and transform-react-jsx-self from your Babel config
   7 | ReactDOM.render(
   8 |   <React.StrictMode>
>  9 |     <App />
     |     ^^^^^^^
  10 |   </React.StrictMode>,
  11 |   document.getElementById('root')
  12 | );
看看这个答案

另请参阅:

更新@babel/core和@babel/plugin-jsx

npm update @babel/core @babel/plugin-transform-react-jsx
or
yarn upgrade @babel/core @babel/plugin-transform-react-jsx
然后添加一个文件
.babelrc

// If you're using @babel/plugin-transform-react-jsx
{
  "plugins": [
    ["@babel/plugin-transform-react-jsx", {
      "runtime": "automatic"
    }]
  ]
}


我已经看过了,但这是指什么巴贝尔配置?这个答案和我看到的错误消息要求我更改一个我找不到的配置文件。我认为你应该遵循并升级@babel/core&@babel/plugin transform jsxunfortute,我已经看到了。我已经按照它所说的那样进行了更新(仍然会出现错误),然后它告诉我将预设更改为“运行时”:“自动”,而不告诉我具有该设置的配置文件在哪里。我认为您应该创建一个
.babelrc
文件并将其添加到那里。我已经更新了答案。这终于解决了我的问题。我想向其他任何人澄清,我在src目录中用我的其余代码创建了这个文件。
// If you're using @babel/plugin-transform-react-jsx
{
  "plugins": [
    ["@babel/plugin-transform-react-jsx", {
      "runtime": "automatic"
    }]
  ]
}