美文网首页React Native学习之路
rn使用vscode直接调试配置

rn使用vscode直接调试配置

作者: 小木工_aedc | 来源:发表于2022-07-28 16:03 被阅读0次

    安装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"
      },
    

    相关文章

      网友评论

        本文标题:rn使用vscode直接调试配置

        本文链接:https://www.haomeiwen.com/subject/tejxwrtx.html