React Native Expo开发构建报错“_traverse.visitors.environmentVisitor is not a function”求助
React Native Expo开发构建报错“_traverse.visitors.environmentVisitor is not a function”求助
各位大佬,我最近把React Native项目升级到0.76.9,同时把Expo升级到了52.0.46。现在生产构建能正常跑,但开发构建一启动就报这个错:
ERROR node_modules\expo\AppEntry.js: [BABEL] C:\u\bob\Home\react-native2\SermonEngagement\node_modules\expo\AppEntry.js: _traverse.visitors.environmentVisitor is not a function
我之前查过相关问题,看到说这个问题在@babel/traverse 7.25.0版本里已经修复,只要升级到这个版本及以上就能解决。但看我的package.json,明明已经用了@babel/traverse 7.27.0(比7.25.0还新),却还是踩坑了:
{ "main": "node_modules/expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", "publish-app": "expo publish", "eject": "expo eject", "lint": "eslint . --ext .js" }, "dependencies": { "@expo-google-fonts/lato": "^0.2.3", "@expo-google-fonts/oswald": "^0.2.3", "@fobos531/react-native-render-html": "^6.4.1", "@react-native-async-storage/async-storage": "1.23.1", "@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-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", "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.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" }, "devDependencies": { "@babel/core": "^7.26.10", "@babel/plugin-proposal-unicode-property-regex": "^7.18.6", "@babel/traverse": "^7.27.0", "@eslint/js": "^9.26.0", "@react-native-community/eslint-config": "^3.2.0", "eslint": "^9.26.0", "eslint-plugin-react": "^7.37.5", "globals": "^16.0.0", "prettier": "^3.0.3" }, "private": true }
后来我抱着试试看的心态,把@babel/traverse回退到7.25.0,结果居然正常了!虽然暂时能用,但我觉得这不算彻底解决——毕竟做了五十多年开发,见过不少版本迭代里修复了旧bug又引入新bug的情况,7.27.0作为后续版本反而出现这个问题,肯定是哪里出问题了。有没有大佬遇到过类似情况,或者知道怎么在不回退版本的前提下解决这个问题?
内容来源于stack exchange




