安装React Native Tools
工具流程就不多说了,随便都能搜到
安装之后配置Debug iOS
,每次启动调试都报错,报错信息如下
Launching the application
An error occurred while launching the application. Cannot find module '/Users/xmg/Desktop/rn/AwesomeProje
ct/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/findXcodeProject
Require stack:
/Users/xmg/.vscode/extensions/msjsdiag.vscode-react-native-1.9.2/dist/rn-extension.js
/Applications/Visual Studio Code. app/Contents/Resources/app/out/vs/loader.js
/Applications/Visual Studio Code. app/Contents/Resources/app/out/bootstrap-amd.js
/Applications/Visual Studio Code.app/Contents/Resources/app/out/bootstrap-fork.js (error code 303)
一看见Cannot find module xxx
,第一时间就想到重新安装应该就好了
然后npm install @react-native-community/cli-platform-ios
,重新安装了好几遍,结果还是报相同错误
网上一顿搜索,结果没有竟然没有遇到同样问题的,很懵逼
后面去github上查看react-native-community/cli-platform-ios
源码,发现其commands目录下,根本没有findXcodeProject
文件,而在config目录下有这个文件
顿时发现应该是react-native-community/cli-platform-ios
版本问题,一顿版本验证,发现7.0.1版本下findXcodeProject
文件还在commands目录下,顺利实现vscode调试
附package.json文件dependencies
配置:
"dependencies": {
"@react-native-community/cli-platform-ios": "7.0.1",
"@react-navigation/native": "^6.0.11",
"react": "18.0.0",
"react-native": "0.69.2",
"react-native-navigation": "^7.28.1",
"react-native-safe-area-context": "^4.3.1"
},
网友评论