Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find module '@babel/plugin-transform-react-jsx-source' when running React App

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.

like image 816
AltBrian Avatar asked Nov 15 '18 20:11

AltBrian


People also ask

How do I enable syntax in jsx?

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”.

Could not find module in path react CJS react jsx runtime Development JS relative to '/ Node_modules react jsx runtime JS?

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!


1 Answers

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!

like image 141
Fernando Rojo Avatar answered Sep 23 '22 20:09

Fernando Rojo