I have just created a React App with create-react-app aquastars
and then eject the dependencies using yarn run eject
and when I run the app I get the following error.
Cannot find module '@babel/plugin-transform-react-jsx-source'
I haven't done anything! What do I need to do to get this up and running? Any help would be appreciated.
The React error “Support for the experimental syntax 'jsx' isn't currently enabled” is caused by not configuring Babel correctly. It can be fixed by creating a . babelrc file in the root of your project directory, and adding the presets “@babel/preset-react” and “@babel/preset-env”.
To solve the error "Cannot find module 'react/jsx-runtime' or its corresponding type declarations", make sure to install the typings for react running the command npm install --save-dev @types/react@latest @types/react-dom@latest and restart your dev server. Copied!
The solution by @xiaobo was actually insufficient for me. It took me a while to figure this out after upgrading expo to v32, so here's what I did in case anyone else has the same problem. (Answer from expo forums.)
If you have a .babelrc
file in the root of your repository, re-name it to something like .babelrc-old
so it doesn't get used.
Add a file called babel.config.js
to the root of your repository.
Put this in the babel.config.js file:
module.exports = function(api) { api.cache(true); return { presets: ['babel-preset-expo'], }; };
All set!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With