Expo Doctor排除react-native-track-player后导致开发构建打包失败的问题求助
各位好,想请教个我遇到的Expo配置相关的奇怪问题:
我用Expo搭建了一个React Native应用,之前跑npx -y expo-doctor的时候,收到了react-native-track-player不兼容新架构的错误提示。根据错误信息里的建议,我在package.json里的expo配置中添加了Doctor的排除规则,具体是这样写的:
"expo": { "doctor": { "reactNativeDirectoryCheck": { "enabled": true, "exclude": ["react-native-track-player"], "listUnknownPackages": false } } }
按照Expo文档的说明,这个配置只是用来调整npx expo-doctor的检测行为,设置完之后确实所有Doctor的错误和警告都消失了,当时还挺庆幸的。
但问题来了:我基于原本正常运行的代码构建了dev-client版本,启动的时候却直接报错了,Android打包失败,具体错误是:
Android Bundling failed 360248ms node_modules\expo\AppEntry.js (1528 modules) Unable to resolve "react-native-track-player/lib/trackPlayer" from "src\features\sermons\screens\engagement.screen.js"
我完全没改其他代码,之后又构建了预览版本,结果预览版里track-player运行得毫无问题,一切正常。直到我把package.json里exclude列表中的react-native-track-player移除掉,dev-client版本才又能正常启动打包了。
我现在的困惑是:为什么Expo Doctor的排除配置会影响到dev-client的打包解析?我本来以为这个配置只是跳过检测而已。下面是我当前(移除排除后的)package.json里的依赖部分,供参考:
"dependencies": { "@expo-google-fonts/lato": "^0.2.3", "@expo-google-fonts/oswald": "^0.2.3", "@expo/config": "^10.0.0", "@fobos531/react-native-render-html": "^6.4.1", "@react-native-async-storage/async-storage": "1.23.1", "@react-native-community/slider": "4.5.5", "@react-native-firebase/analytics": "^18.6.0", "@react-native-firebase/app": "^18.6.0", "@react-native-masked-view/masked-view": "0.3.2", "@react-navigation/bottom-tabs": "^6.4.3", "@react-navigation/native": "^6.0.16", "@react-navigation/stack": "^6.3.7", "camelize": "^1.0.0", "expo": "^52.0.46", "expo-application": "~6.0.2", "expo-av": "~15.0.2", "expo-build-properties": "~0.13.2", "expo-constants": "~17.0.8", "expo-dev-client": "~5.0.20", "expo-device": "~7.0.3", "expo-keep-awake": "~14.0.3", "expo-linear-gradient": "~14.0.2", "expo-module-scripts": "~4.0.5", "expo-splash-screen": "~0.29.24", "expo-status-bar": "~2.0.1", "expo-updates": "~0.27.4", "find-yarn-workspace-root": "^2.0.0", "firebase": "^10.4.0", "jest-expo": "~52.0.6", "lottie-react-native": "7.1.0", "react": "^18.3.1", "react-native": "0.76.9", "react-native-elements": "^3.4.3", "react-native-exit-app": "^2.0.0", "react-native-gesture-handler": "~2.20.2", "react-native-paper": "^5.10.6", "react-native-safe-area-context": "4.12.0", "react-native-screens": "~4.4.0", "react-native-svg": "15.8.0", "react-native-track-player": "4.0", "react-native-vector-icons": "^10.0.0", "react-native-web": "~0.19.13", "react-native-webview": "13.12.5", "stripe-client": "^1.1.5", "styled-components": "^6.0.9" }
我实在搞不懂,为什么这个Doctor的排除配置会影响到dev-client的模块解析?有没有哪位大佬遇到过类似的问题,或者知道这是哪里出了问题?我既想让Expo Doctor保持“干净”,又不想影响dev-client的正常使用,该怎么调整配置呢?
内容来源于stack exchange

