Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransformError Cannot read property 'throwIfClosureRequired' of undefined #18969

Closed
3 tasks
jinsandazi opened this issue Apr 22, 2018 · 25 comments
Closed
3 tasks
Labels
Resolution: Fixed A PR that fixes this issue has been merged. Resolution: Locked This issue was locked by the bot.

Comments

@jinsandazi
Copy link

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

@react-native-bot
Copy link
Collaborator

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.

@CoericK
Copy link

CoericK commented Apr 22, 2018

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

@yinjiaoyuan
Copy link

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

@liam-thunder
Copy link

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

@eowfenth
Copy link

duplicate of #18962

@jinaddavid
Copy link

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

@luaenrique
Copy link

Same problem here...

@MichelDiz
Copy link

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

@MichelDiz
Copy link

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

@nikenrp
Copy link

nikenrp commented Apr 22, 2018

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.

@mruhnau
Copy link

mruhnau commented Apr 22, 2018

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

@jinsandazi
Copy link
Author

I use react-native init xxxx --version 0.44

@hiradary
Copy link

@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"
  }
}

@yankouskia
Copy link

yankouskia commented Apr 22, 2018

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.

@hiradary
Copy link

hiradary commented Apr 22, 2018

@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

@dengue8830
Copy link

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"
  }
}

@dluksza
Copy link

dluksza commented Apr 23, 2018

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

@yildiz
Copy link

yildiz commented Apr 23, 2018

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

@m0v006c
Copy link

m0v006c commented Apr 24, 2018

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

@MichelDiz
Copy link

MichelDiz commented Apr 24, 2018

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

@MichelDiz
Copy link

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.

@m0v006c
Copy link

m0v006c commented Apr 24, 2018

@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

@MichelDiz
Copy link

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

@dengue8830
Copy link

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

@m0v006c
Copy link

m0v006c commented Apr 25, 2018

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

@react-native-bot react-native-bot added the Resolution: Fixed A PR that fixes this issue has been merged. label May 18, 2018
@facebook facebook locked as resolved and limited conversation to collaborators May 18, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Fixed A PR that fixes this issue has been merged. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests