React Native应用程序:bundleReleaseJsAndAssets错误:“ decorators”插件需要一个“ decoratorsBeforeExport”选项

时间:2018-12-12 19:52:14

标签: react-native react-native-android bundle-release-js-and-assets

当我运行./gradlew assembleRelease时,我得到此错误:

Task :app:bundleReleaseJsAndAssets 
warning: the transform cache was reset.
Loading dependency graph, done.

index.js: 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'.

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

我没有使用@Babel,而是在我的package.json文件中使用了babel:

{
  "name": "my-app",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@ptomasroos/react-native-multi-slider": "0.0.12",
    "firebase": "^5.1.0",
    "javascript-time-ago": "^1.0.30",
    "mobx": "^4.1.1",
    "mobx-react": "^5.0.0",
    "native-base": "^2.8.1",
    "prop-types": "^15.6.2",
    "protobufjs": "^6.8.8",
    "react": "16.2.0",
    "react-native": "^0.57.7",
    "react-native-actionsheet": "^2.3.0",
    "react-native-aws3": "0.0.8",
    "react-native-axios": "^0.17.1",
    "react-native-billing": "^2.9.1",
    "react-native-card-stack-swiper": "^1.0.5",
    "react-native-collapsible": "^0.10.0",
    "react-native-cookies": "^3.2.0",
    "react-native-datepicker": "^1.6.0",
    "react-native-dropdownalert": "^3.5.0",
    "react-native-elements": "^0.19.0",
    "react-native-event-listeners": "^1.0.3",
    "react-native-expandable-section-flatlist": "^1.0.3",
    "react-native-fbsdk": "^0.8.0",
    "react-native-fcm": "^16.0.0",
    "react-native-floating-action": "^1.10.1",
    "react-native-geocoding": "^0.3.0",
    "react-native-gifted-chat": "^0.4.3",
    "react-native-google-places-autocomplete": "^1.3.6",
    "react-native-hide-show-password-input": "^1.0.7",
    "react-native-image-crop-picker": "^0.19.3",
    "react-native-image-picker": "^0.26.10",
    "react-native-image-placeholder": "^1.0.14",
    "react-native-instagram-login": "^1.0.7",
    "react-native-keyboard-aware-scroll-view": "^0.4.4",
    "react-native-keyboard-aware-scrollview": "^2.0.0",
    "react-native-keyboard-spacer": "^0.4.1",
    "react-native-linear-gradient": "^2.4.0",
    "react-native-linkedin": "^1.3.1",
    "react-native-localization": "^2.0.0",
    "react-native-material-bottom-navigation": "^0.9.0",
    "react-native-modal-datetime-picker": "^6.0.0",
    "react-native-open-settings": "^1.0.1",
    "react-native-pages": "^0.7.0",
    "react-native-permissions": "^1.1.1",
    "react-native-picker-select": "^5.1.0",
    "react-native-popup-menu": "^0.12.4",
    "react-native-pulse": "^1.0.6",
    "react-native-scrollable-tab-view": "^0.8.0",
    "react-native-share": "^1.0.26",
    "react-native-simple-toast": "0.0.8",
    "react-native-snap-carousel": "^3.7.2",
    "react-native-splash-screen": "^3.0.6",
    "react-native-star-rating": "^1.0.9",
    "react-native-swipe-cards": "^0.1.1",
    "react-native-swipe-list-view": "^1.0.7",
    "react-native-swipeable-flat-list": "0.0.5",
    "react-native-swipeout": "^2.3.3",
    "react-native-switch": "^1.4.0",
    "react-native-twitter-signin": "github:GoldenOwlAsia/react-native-twitter-signin#master",
    "react-native-view-more-text": "^2.0.1",
    "react-native-viewpager": "^0.2.13",
    "react-navigation": "^1.0.3",
    "rn-viewpager": "^1.2.9"
  },
  "devDependencies": {
    "babel-jest": "22.2.2",
    "babel-plugin-transform-decorators-legacy": "^1.3.4",
    "babel-preset-react-native": "4.0.0",
    "jest": "22.2.2",
    "react-test-renderer": "16.2.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

1 个答案:

答案 0 :(得分:1)

我终于通过安装以下软件包来解决了这个问题:@babel/plugin-proposal-decorators并删除了这个软件包:babel-plugin-transform-decorators-legacy

最后将我的.babelrc的插件部分更改为此:

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