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

upgrade to react native 0.57 throws error #21320

Closed
adirzoari opened this issue Sep 25, 2018 · 12 comments
Closed

upgrade to react native 0.57 throws error #21320

adirzoari opened this issue Sep 25, 2018 · 12 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.

Comments

@adirzoari
Copy link

adirzoari commented Sep 25, 2018

Environment

  React Native Environment Info:
    System:
      OS: Windows 10
      CPU: x64 Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
      Memory: 4.52 GB / 15.91 GB
    Binaries:
      Yarn: 1.5.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.3.0 - C:\Program Files\nodejs\npm.CMD

Description

I upgraded from react-naitve 0.55.4 to react-native 0.57.0 and I get this error
bundling failed: Error: The 'decorators' plugin requires a 'decoratorsBeforeExport' option, whose value must be a boolean. If you are migrating from Babylon/Babel 6 or want to use the old decorators proposal, you should use the 'decorators-legacy' plugin instead of 'decorators'.

my package .json

`{
  "name": "APP_PROJECTXXX",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "appcenter": "^1.8.1",
    "appcenter-analytics": "^1.8.1",
    "appcenter-crashes": "^1.8.1",
    "lodash": "^4.17.10",
    "mobx-react-navigation-store": "^1.4.4",
    "moment": "^2.22.2",
    "react": "16.5.0",
    "react-native": "^0.57.0",
    "react-native-config": "^0.11.5",
    "react-native-confirmation-code-input": "^1.0.4",
    "react-native-datepicker": "^1.7.2",
    "react-native-device-info": "^0.22.5",
    "react-native-iphone-x-helper": "^1.1.0",
    "react-native-map-link": "^2.1.0",
    "react-native-onesignal": "^3.2.6",
    "react-native-vector-icons": "^5.0.0",
    "react-navigation": "^1.0.0-beta.21"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.3",
    "babel-jest": "22.4.3",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-react-native": "4.0.0",
    "eslint": "^4.19.1",
    "eslint-plugin-react": "^7.7.0",
    "jest": "22.4.3",
    "react-test-renderer": "16.3.1"
  },
  "jest": {
    "preset": "react-native",
    "setupFiles": [
      "<rootDir>\\node_modules\\appcenter\\test\\AppCenterMock.js",
      "<rootDir>\\node_modules\\appcenter-analytics\\test\\AppCenterAnalyticsMock.js",
      "<rootDir>\\node_modules\\appcenter-crashes\\test\\AppCenterCrashesMock.js"
    ]
  }
}

`

@hahtml
Copy link

hahtml commented Sep 25, 2018

Notice that RN0.57 uses babel 7. You need to do some migration stuff using babel-upgrade tool.
https://github.com/babel/babel-upgrade
Also, babel-plugin-transform-decorators-legacy is renamed to @babel/plugin-proposal-decorators
with a legacy flag in babel.rc file.

@adirzoari
Copy link
Author

hey, what do you mean legacy in babel.rc? can you show me example what to do please? I stuck for some hours

@hahtml
Copy link

hahtml commented Sep 25, 2018

could u show me your babel.rc file? Also, you need to use metro-react-native-babel-preset instead of react-native in preset config. See the description https://www.npmjs.com/package/babel-preset-react-native

@adirzoari
Copy link
Author

my babel.rc
{ "presets": ["react-native"], "plugins": ["transform-decorators-legacy"] }

@hahtml
Copy link

hahtml commented Sep 25, 2018

@adirzoari Try to use https://github.com/babel/babel-upgrade to migrate to babel 7. It will do everything for u.

@hramos hramos added the Type: Question Issues that are actually questions and not bug reports. label Sep 25, 2018
@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Sep 25, 2018
@react-native-bot
Copy link
Collaborator

We are using GitHub issues exclusively to track bugs in React Native. GitHub may not be the ideal place to ask a question, but you can try asking over on Stack Overflow, or on Reactiflux. You may also use discuss.reactjs.org/ to discuss best practices.

@yaoyingjiang
Copy link

@adirzoari do you solve this issue? i have same an issue

@adirzoari
Copy link
Author

yes. my problem was that I removed node_modules and then installed with npm and not in yarn. so I deleted package_lock.json and install with yarn install

@McMainsLiam
Copy link

McMainsLiam commented Oct 22, 2018

Here is what I did to fix the issue; I hope it can help someone else!

First install the new proposal decorators with npm install @babel/plugin-proposal-decorators --save-dev or yarn add @babel/plugin-proposal-decorators --dev

Then, inside of your .babelrc file, change this:

{
  "presets": ["react-native"],
  "plugins": ["transform-decorators-legacy"]
}

To this:

{
  "presets": [
    "module:metro-react-native-babel-preset",
    "@babel/preset-flow"
  ],
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy" : true }]
  ]
}

EDIT:

After you've updated your .babelrc file, make sure to add preset-flow as well with the command yarn add @babel/preset-flow --dev or npm install @babel/preset-flow --save-dev

Thanks @dileepbolisetti!

@dileepbolisetti
Copy link

@spiritman110 i had to run "yarn add@babel/preset-flow" after the steps you mentioned. (y)

@ahmdsdk
Copy link

ahmdsdk commented Oct 30, 2018

I've just updated to react-native 0.57 and got the same error. I tried all that is mentioned above (tried the babel upgrade tool on the link https://github.com/babel/babel-upgrade also tried @spiritman110 solution, but I'm still getting the same error.

This is my updated package.json file:

"dependencies": {
    "mobx": "^4.2.0",
    "mobx-react": "^5.2.2",
    "react": "16.3.0",
    "react-native": "^0.57.4"
 },
  "devDependencies": {
    "@babel/core": "^7.0.0",
    "@babel/plugin-proposal-decorators": "^7.1.2",
    "@babel/preset-flow": "^7.0.0",
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "^23.4.2",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.4.3",
    "react-test-renderer": "16.3.0"
  },
  "rnpm": {
    "assets": [
      "./assets/fonts/"
    ]
  },
  "jest": {
    "preset": "react-native"
  }

and this is my updated .babelrc file:

{
  "presets": [
    "module:metro-react-native-babel-preset",
    "@babel/preset-flow"
  ],
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy" : true }]
  ]
}

I deleted node modules and used yarn to install.

yarn -v 1.12.1
node -v 11.0.0
npm -v 6.4.1

Can anyone tell me what am I missing here? Any help would be appreciated.

@lironhl
Copy link

lironhl commented Feb 5, 2019

@ahmdsdk you need to download metro-react-native-babel-preset

npm i metro-react-native-babel-preset

@facebook facebook locked as resolved and limited conversation to collaborators Sep 25, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Sep 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot. Type: Question Issues that are actually questions and not bug reports.
Projects
None yet
Development

No branches or pull requests

9 participants