gpt4 book ai didi

android - 错误: Requiring module "node_modules\react-native-reanimated\src\Animated.js"

转载 作者:行者123 更新时间:2023-12-02 01:49:32 31 4
gpt4 key购买 nike

我正在 React Native Expo 中制作一个应用程序。它可以在网络浏览器上运行,但无法在我手机上的 Android 模拟器或 expo go 应用程序上运行。我收到 2 个错误:-

错误:需要模块“node_modules\react-native-reanimated\src\Animated.js”,抛出异常:错误:Reanimated 2 未能创建工作集,也许您忘记添加 Reanimated 的 babel 插件?

不变违规:“main”尚未注册。如果出现以下情况,就会发生这种情况:

  • Metro(本地开发服务器)从错误的文件夹运行。检查 Metro 是否正在运行,停止它并在当前项目中重新启动它。

如有任何帮助,我们将不胜感激

我的世博 SDK:44,

我的package.json

    {
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@react-native-async-storage/async-storage": "~1.15.0",
"@react-native-community/masked-view": "^0.1.10",
"axios": "^0.24.0",
"expo": "^44.0.0",
"expo-status-bar": "~1.2.0",
"ngrok": "^4.2.2",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-gesture-handler": "~2.1.0",
"react-native-reanimated": "~2.3.1",
"react-native-safe-area-context": "3.3.2",
"react-native-screens": "~3.10.1",
"react-native-web": "0.17.1",
"react-navigation": "^4.4.4",
"react-navigation-stack": "^2.10.4",
"react-navigation-tabs": "^2.11.0",
"react-native-maps": "0.29.4"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}

我的 babel.config

module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: ["react-native-reanimated/plugin"],
};
};

最佳答案

正如reanimated中提到的doc ,

  • 安装yarn添加react-native-reanimated@next
  • 编辑 babel 插件配置
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
plugins: ['react-native-reanimated/plugin'],
};
};
  • 清除 Metro Bundler 缓存并启动 expo expo start --clear

这应该可以解决问题!

关于android - 错误: Requiring module "node_modules\react-native-reanimated\src\Animated.js",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70493915/

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