react-native init (0.57) Cannot find module '@babel/plugin-external-helpers'

Viewed 3094

When I create a brand new react native project, I get this error message:

Cannot find module '@babel/plugin-external-helpers'

My package.json file:

{
  "name": "TestProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.5.0",
    "react-native": "0.57.0"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.45.4",    
    "react-test-renderer": "16.5.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Any idea what is wrong?

Thank you.

8 Answers

Same thing for me, just run

npm install --save-dev @babel/plugin-external-helpers

and it should works

just install @babel/plugin-external-helpers, no need to change .babelrc For me, fixed this issue by installing @babel/plugin-external-helpers and react-transform-hmr.

Run:

npm install --save-dev @babel/plugin-external-helpers
npm install react-transform-hmr

The other answers probably work if you didn't update XCode. Upgrading react-native, XCode, and my iOS all in the span of a couple days completely broke everything.

Starting a new project to test with react-native 0.57, I encountered the same problem you did, and installed the package, however that did not solve the problem. I'd seen another post talking about the build system change in XCode 10, so I tried that and this worked for me:

  1. npm install --save-dev @babel/plugin-external-helpers as mentioned
  2. Open the project in XCode
  3. Go to File > Project Settings
  4. Change Build System to Legacy Build System

We got same error here! We can't run any react native project (both iOS and Android). Those projects use react-native version 0.56.0.

If we create a project with react-native version 0.42.0 it works: react-native init [project_name] --version 0.42.0

Although using npm install --save-dev @babel/plugin-external-helpers does not work for us. Neither using npm install react-transform-hmr.

Using yarn, just running:

yarn add --dev @babel/plugin-external-helpers

worked for me.

Just installed a new project and it seems fixed.

New version of the metro-react-native-babel-preset package.

Below the package.json file I get after a fresh install.

"metro-react-native-babel-preset": "0.45.5"

{
  "name": "ZStyleCachedImage",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.5.0",
    "react-native": "0.57.0"
  },
  "devDependencies": {
    "babel-jest": "23.6.0",
    "jest": "23.6.0",
    "metro-react-native-babel-preset": "0.45.5",
    "react-test-renderer": "16.5.0"
  },
  "jest": {
    "preset": "react-native"
  }
}
Related