AltBrian
AltBrian

Reputation: 2562

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.

Upvotes: 31

Views: 44686

Answers (7)

Martin
Martin

Reputation: 6146

On my Windows 10 system this error was caused by switching to git-bash (as the default shell used by npm to run any scripts from package.json). I had previously done npm config set script-shell "C:\Program Files\Git\bin\bash.exe" in another project to be able to run any scripts that contained bash syntax. I could revert it via npm config delete script-shell and the error was gone. more

Upvotes: 0

xiaobo
xiaobo

Reputation: 651

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

Upvotes: 27

ham118
ham118

Reputation: 31

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

Upvotes: -1

malcode
malcode

Reputation: 39

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

Upvotes: 3

Fernando Rojo
Fernando Rojo

Reputation: 3218

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!

Upvotes: 44

drfenixion
drfenixion

Reputation: 44

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

Upvotes: 1

RKM
RKM

Reputation: 144

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

Upvotes: 8

Related Questions