I am getting this error when I run npm run in a react app:
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 | );
I don't have a babel config file in my project and I can't find the config file react is already using. How do I resolve this?
package.json dependencies (I have run npm run eject before but have not pasted all dependencies to make this shorter):
"dependencies": {
"@babel/core": "^7.14.3",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.6.0",
"babel-loader": "8.1.0",
"babel-plugin-named-asset-import": "^0.3.7",
"babel-preset-react": "^6.24.1",
"babel-preset-react-app": "^10.0.0",
"bfj": "^7.0.2",
"html-webpack-plugin": "4.5.0",
"identity-obj-proxy": "3.0.0",
"jest": "26.6.0",
"jest-circus": "26.6.0",
"jest-resolve": "26.6.0",
"jest-watch-typeahead": "0.6.1",
"react": "^17.0.2",
"react-app-polyfill": "^2.0.0",
"react-dev-utils": "^11.0.3",
"react-dom": "^17.0.2",
"react-refresh": "^0.8.3",
"semver": "7.3.2",
"style-loader": "1.3.0",
"terser-webpack-plugin": "4.2.3",
"ts-pnp": "1.2.0",
"url-loader": "4.1.1",
"web-vitals": "^1.0.1",
"webpack": "4.44.2",
"webpack-dev-server": "3.11.1",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "5.1.4"
},
Check out this answer React Native Jest SyntaxError: Duplicate __self prop found
Also refer: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html
Update @babel/core and @babel/plugin-transform-react-jsx
npm update @babel/core @babel/plugin-transform-react-jsx
or
yarn upgrade @babel/core @babel/plugin-transform-react-jsx
then add a file .babelrc
// If you're using @babel/plugin-transform-react-jsx
{
"plugins": [
["@babel/plugin-transform-react-jsx", {
"runtime": "automatic"
}]
]
}