代码之家  ›  专栏  ›  技术社区  ›  lampShadesDrifter

突然看到错误“插件/预设文件不允许导出对象,只允许函数”在创建react本机应用程序项目中

  •  13
  • lampShadesDrifter  · 技术社区  · 6 年前

    一直致力于通过 create-react-native-app . 已经成功使用该项目一段时间了,但现在正在尝试通过 exp start --tunnel ,我突然看到了表单的错误(尽管以前工作过):

    [22:08:19] /path/to/node_modules/react-native-scripts/build/bin/crna-entry.js: Plugin/Preset files are not allowed to export objects, only functions. In /path/to/node_modules/babel-preset-expo/index.js
    [22:08:19] Failed building JavaScript bundle.
    

    看到一些帖子似乎在处理这个问题( https://github.com/babel/babel/issues/6808 Babel Plugin/Preset files are not allowed to export objects, only functions 但是我对任何事情的反应都是全新的,不完全理解 bable 也就是说,我很难理解如何将这些帖子应用到我自己的情况中。

    我的.bablerc文件(在其他帖子中似乎是相关的)是:

    {
      "presets": ["babel-preset-expo"],
      "env": {
        "development": {
          "plugins": ["transform-react-jsx-source"]
        }
      }
    }
    

    已经试过了 npm cache clean --force && rm -rf node_modules && rm -f package-lock.json && npm install 没有变化。 似乎有帮助的是将react-native@0.56降级为0.55 (如本文所述: Create React Native App. - Plugin/Preset files are not allowed to export objects, only functions 但这似乎不能直接解决 解决方法 . 关于应该在这里做什么的任何建议都会受到欢迎(应该包括任何其他文件来帮助调试?).


    **作为对该问题的回应,该问题被标记为 创建React Native应用程序。-插件/预设文件不允许导出对象,只有函数 ,

    1. 这一问题在文章中被引用,并解释了为什么这个问题被发表,尽管在最后一段中包含了另一个问题。
    2. 我稍后的答复 向其他用户解释问题 为什么?
    3 回复  |  直到 6 年前
        1
  •  18
  •   lampShadesDrifter    6 年前

    npm update

    https://facebook.github.io/react-native/docs/upgrading.html#create-react-native-app-projects react-native react expo https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md

    ...
    "dependencies": {
        "@expo/vector-icons": "^6.3.1",
        "eslint": "^4.19.1",
        "expo": "^27.1.0",
        "prop-types": "^15.6.2",
        "react": "16.3.1",
        "react-native": "^0.55.4",
        "react-native-mail": "^3.0.6",
        "react-native-modal-dropdown": "^0.6.2",
        "react-navigation": "^2.6.2",
        "react-redux": "^5.0.7",
        "redux": "^4.0.0",
        "tcomb-form-native": "^0.6.14",
        "uuid": "^3.3.2"
      }
    }
    
        2
  •  10
  •   user2209783    6 年前

    npm install react-native@0.55.0
    
        3
  •  1
  •   Radhwane Chebaane    6 年前

    https://github.com/expo/react-native/

    "react-native": "https://github.com/expo/react-native/archive/sdk-29.0.0.tar.gz",