VSCode debug Expo project: “Debug adapter process

2019-08-28 16:21发布

问题:

I try to use vscode to debug Expo project. The expo works fine, setting are as bellow:

Expo XDE: Host: Tunnel
          Development Mode
iOS Simulator: Enable Remote Debugging

But when I add Debug in Exponent in VSCode, and click debug, it will pop up Debug adapter process has terminated unexpectedly without showing any further information. DEBUG CONSOLE show nothing.

What should I do to finding out what's going on ?

By the way, I didn't see the file ${workspaceRoot}/.vscode/launchReactNative.js but I have see someone said that this file is not needed.

回答1:

  • instead of 'debug in exponent' select 'attach to packager' (but dont click the green arrow yet)
  • change the packager port (because expo packager defaults to 19001 instead of 19000)) by adding the line "react-native.packager.port": 19001 to user's settings.json
  • run the app on metro's web ui or by command line (npm run ios/android [or yarn])
  • click the green arrow to start debuging on vscode
  • then start the "Remote JS Debugging" on simulator, emulator or device