gpt4 book ai didi

react-native - 在 create-react-native-app 项目中突然看到错误 "Plugin/Preset files are not allowed to export objects, only functions"

转载 作者:行者123 更新时间:2023-12-03 23:13:28 25 4
gpt4 key购买 nike

一直致力于通过 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/6808Babel Plugin/Preset files are not allowed to export objects, only functions ),但我对任何 react 都是全新的,并没有完全理解 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 ),但这似乎并没有直接解决问题,而是一种解决方法。任何关于这里应该做什么的建议将不胜感激(应该包含任何其他文件来帮助调试?)。

** 针对此问题被标记为 Create React Native App. - Plugin/Preset files are not allowed to export objects, only functions 的潜在重复项,
  • 这个问题实际上是在帖子中引用的,尽管最后一段中包含了另一个问题,但为什么要发布这个问题的解释
  • 我后来对这个问题的回答向其他用户解释了为什么降级到 0.55 解决了这个问题(并引用了用户可以进一步检查的相关文档),这(在发布这个问题时)在另一个引用的问题中不存在(尽管目前,将此问题标记为重复的用户现在在引用的问题中有一个答案,该答案也讨论了为什么 0.55 降级有效)。
  • 最佳答案

    发现问题是这样的:

    在某些时候,一定做了一个 npm update将 react-native 更新为 0.56,将 expo 更新为 28.0.0。

    查看 react-native 文档( https://facebook.github.io/react-native/docs/upgrading.html#create-react-native-app-projects ),react-native 似乎是 需要安装 react-native 的版本, react , 和 expo彼此特别兼容 .可以在此处找到哪些软件包的哪些版本相互兼容的矩阵:https://github.com/react-community/create-react-native-app/blob/master/VERSIONS.md并说

    Each version of these dependencies is only compatible with a narrow version range of the other two.



    在撰写本文时,该文档的最后更新时间为 2018 年 4 月 27 日,因此尚不清楚应该将哪些版本的 react 和 expo(最近发布的版本为 28.0.0)与现已推出的 react-native 结合使用@0.56。记录的最新 react-native 版本是 react-native@0.55(与 react@16.3.1 和 expo@27.0.0 一起使用),我认为这就是为什么 在这种情况下,降级到 react-native@0.55 很有帮助 (我不知道为什么在 react-native@0.56 矩阵中还没有文档),我的 package.json 现在看起来像:
    ...
    "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"
    }
    }

    关于react-native - 在 create-react-native-app 项目中突然看到错误 "Plugin/Preset files are not allowed to export objects, only functions",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51241109/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com