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

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 (<anonymous>)\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

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 25

Most upvoted comments

Downgraded this and solves yarn add -D babel-preset-react-native@4.0.0

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

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.

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

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

@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

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