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

Viewed 35622

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.

6 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!

After you execute npm run eject:

  1. cd /your/project/path (ignore)
  2. rm -rf node_modules
  3. npm install or yarn install
  4. Run the script, which was failing before (in your case most likely: yarn start or npm start).

Delete the whole node_modules and re-run yarn to make it work. rm -R node_modules/ rm yarn.lock yarn install

In my case, it was solved by installing, on Reactjs, "@babel", @babel/plugin-transform-react-jsx

1: yarn add @babel/plugin-transform-react-jsx
2: yarn start

Try to replace '@babel/plugin-transform-react-jsx-source' with '@babel/transform-react-jsx-source'

Vanished this error after just changed the name of “.babelrc” file which was at the root of the repository.

Related