【发布时间】:2022-01-26 07:49:34
【问题描述】:
我正在 react native expo 中制作应用程序。它在网络浏览器上运行,但无法在我的手机上的 android 模拟器或 expo go 应用程序上运行。我得到 2 个错误:-
Error: Requiring module "node_modules\react-native-reanimated\src\Animated.js",抛出异常:Error: Reanimated 2 failed to create a worklet,也许你忘了添加Reanimated的babel插件?
不变违规:“main”尚未注册。在以下情况下可能会发生这种情况:
- Metro(本地开发服务器)从错误的文件夹运行。检查 Metro 是否正在运行,将其停止并在当前项目中重新启动。
任何帮助将不胜感激
我的 expo 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"],
};
};
【问题讨论】:
标签: android node.js react-native expo babeljs