React-native: TransformError Cannot read property 'throwIfClosureRequired' of undefined

Created on 22 Apr 2018  路  25Comments  路  Source: facebook/react-native


my node version is v8.11.1
npm version 5.8.0

my package.json content :

{
"name": "FirstRn2",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "^16.3.1",
"react-native": "0.55.3"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-plugin-transform-es2015-block-scoping": "^6.26.0",
"babel-preset-react-native": "5.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}

when I run : react-native run-android I get this:

{"type":"TransformError","lineNumber":0,"errors":[{"description":"/Users/wangpeng/Desktop/testRN/FirstRn3/index.js: Cannot read property 'throwIfClosureRequired' of undefined (While processing preset: \"/Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-preset-react-native/index.js\")","lineNumber":0}],"name":"SyntaxError","message":"/Users/wangpeng/Desktop/testRN/FirstRn3/index.js: Cannot read property 'throwIfClosureRequired' of undefined (While processing preset: \"/Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-preset-react-native/index.js\")","stack":"TypeError: Cannot read property 'throwIfClosureRequired' of undefined (While processing preset: \"/Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-preset-react-native/index.js\")\n at _default (/Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-preset-react-native/node_modules/@babel/plugin-transform-block-scoping/lib/index.js:19:36)\n at Function.memoisePluginContainer (/Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-core/lib/transformation/file/options/option-manager.js:113:13)\n at Function.normalisePlugin (/Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-core/lib/transformation/file/options/option-manager.js:146:32)\n at /Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30\n at Array.map ()\n at Function.normalisePlugins (/Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)\n at OptionManager.mergeOptions (/Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)\n at /Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14\n at /Users/wangpeng/Desktop/testRN/FirstRn3/node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22"}

I really hope someone can help me, thanks very very much!!!!!!!

Environment

Steps to Reproduce

Expected Behavior

Actual Behavior

Fixed Locked

Most helpful comment

Downgraded this and solves
yarn add -D [email protected]

All 25 comments

Thanks for posting this! It looks like your issue may be missing some necessary information. Can you run react-native info and edit your issue to include these results under the Environment section?

Thank you for your contributions.

Got the same issue. Just cloned a fresh repo, and tried to run it got the same message.
Environment:
OS: macOS High Sierra 10.13.4
Node: 9.9.0
Yarn: 1.5.1
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.3 Build version 9E145
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.3 => 0.55.3

And I have the same problem. My react-native info:
Environment:
OS: macOS High Sierra 10.13.3
Node: 9.10.1
Yarn: 1.6.0
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.3 Build version 9E145
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.3 => 0.55.3

same problem here.. below I attached the react-native info..
Environment:
OS: Windows 10
Node: 8.11.1
Yarn: 1.6.0
npm: 5.8.0
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.1.0.0 AI-173.4697961

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.3 => 0.55.3

duplicate of #18962

am also having the same problem any solution to this ?

OS: Linux 4.14
Node: 9.2.0
Yarn: 1.3.2
npm: 5.6.0
Watchman: Not Found
Xcode: N/A
Android Studio: Not Found

Packages: (wanted => installed)
react: 16.3.1 => 16.3.1
react-native: 0.55.3 => 0.55.3

Same problem here...

Here too, however, it is surprisingly striking to see the same issue of these already occurring with others two hours ago. It's almost "At Live".

Downgraded this and solves
yarn add -D [email protected]

Just edit the packages.json file and set the version to 4.0.0
After that just run 'npm install' and it will be working again.

I ran into the same issue, downgrading to "babel-preset-react-native": "4.0.0" in the package.json and running npm install afterwards resolves the issue

I use react-native init xxxx --version 0.44

@mruhnau I'm still getting the same error :(
here is my package.json file

{
  "name": "hello",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.0.0",
    "react-native": "0.51.0"
  },
  "devDependencies": {
    "babel-jest": "22.4.3",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.4.3",
    "react-test-renderer": "16.0.0"
  },
  "jest": {
    "preset": "react-native"
  }
}
Environment:
  OS: macOS High Sierra 10.13.4
  Node: 9.11.1
  Yarn: 1.6.0
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.3 Build version 9E145
  Android Studio: Not Found

Same issue. Tried to downgrade babel-preset-react-native, but that did not help.

@yankouskia I got the solution! thanks @marksturm. try this on your terminal:

watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache

you must use --force for the npm cache clean command if your npm version > 5.
so it would be :

watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean --force && npm install && npm start -- --reset-cache

downgrade of babel-preset-react-native worked for me.
this is my package.json (its from a fresh install)

{
  "name": "reactNativeTest",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.3.1",
    "react-native": "0.55.3"
  },
  "devDependencies": {
    "babel-jest": "22.4.3",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.4.3",
    "react-test-renderer": "16.3.1"
  },
  "jest": {
    "preset": "react-native"
  }
}

Same here with babel-preset-react-native 5.0, downgrading did solve this issue.

Downgrade version of babel-preset-react-native worked for me. Thanks.

I am facing same issue. I tried it with changing version but it did not work. Below is my package.json
{
"name": "MyApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.3"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-react-native": "4.0.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}

screen shot 2018-04-24 at 7 36 28 pm

@mverma89 Your error is not related to what's in this issue. Something wrong with your environment. Try doing "yarn start" (our exp start, in the case of Expo) to start the development server. Or evaluate your simulator's situation. There is some communication problem between the simulator and your terminal.

PS: Reading this error again, I think was a bit wrong. But I think I could be a "cache" issue. mverma89 says it solves with some ADB issue, but I really think it's no that case. It's cache and the "clean-install" should solve his error. Just a theory. For those who come to read this in the future.

Add this to your scrips: "clean-install": "rm -rf node_modules && rm -rf $TMPDIR/react-* && npm cache clean --force && watchman watch-del-all && yarn", and run it.

@MichelDiz Thanks for response.
I am very new to react-native. I am simply following [https://facebook.github.io/react-native/docs/getting-started.html] this tutorial and created first project using react-native run-android command.
I run mentioned script but still no luck.
Below is the log after running script:
rm -rf node_modules && rm -rf $TMPDIR/react-* && npm cache clean --force && watchman watch-del-all && yarn
npm WARN using --force I sure hope you know what you are doing.
{
"version": "4.9.0",
"roots": []
}
-bash: yarn: command not found

Sorry, change yarn to "npm install" - or install Yarn in your machine https://yarnpkg.com/lang/en/docs/install/#mac-stable

@mverma89 When you modifiy dependencies in package.json you have to delete your node_modules folder and make a npm install

@MichelDiz @dengue8830 Thank you very much for support. I found the actual issue (adb not found).
After setting path, its working fine. 馃槂

Was this page helpful?
0 / 5 - 0 ratings