gpt4 book ai didi

android - 调试适配器 : SyntaxError: Unexpected token L in JSON at position 0 中未处理的错误

转载 作者:可可西里 更新时间:2023-11-01 14:13:06 25 4
gpt4 key购买 nike

错误:

******** Unhandled error in debug adapter: SyntaxError: Unexpected token L in JSON at position 0    
at JSON.parse (<anonymous>)
at Pipe.channel.onread (internal/child_process.js:471:28)

大家好,

我在这里和其他任何地方发现了很多其他类似的问题/问题,但没有一个包括“调试适配器中未处理的错误”。我尝试了很多工作流程,但没有任何效果。

简介:

操作系统:Windows 64x

IDE:VS Code(版本:1.25.1/launch.json 见下文)

vscode-Plugin:React Native 工具(版本:0.6.12)

语言/框架:React-Native

( react 版本:16.4.1/RN 版本 0.55.4/cli 版本:2.0.1)

项目:Android App(后来是iOS)

React-Native 的输出:运行 android安装 APK“app-debug.apk” 成功。

React-Native 的输出:通过执行以下命令启动自定义调试器:echo 不需要调试器: “[project-location]” “[project-location].vscode”

通过终端启动带有 react-native run-android 的应用程序仍然有效。

尝试以下故障排除步骤:

  • 注释掉所有 JSON.parse() 调用
  • 检查所有基于 fetch 的函数
  • 检查旧版本库修订
  • 修复vscode
  • 重新安装vscode
  • 将 RN 更新到 0.56.0
  • 更换移动设备

现有项目太大,无法在此处显示,并且不存在于公共(public)存储库中。

launch.json - 我正在使用“调试 Android”

{    
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react",
},
{
"name": "Debug iOS",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Attach to packager",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug in Exponent",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
}
]
}

不知道问题出在哪里:

  • 项目
  • vscode
  • 节点
  • ...

Logcat 只打印 [INFO] 没有警告也没有错误。

想用vscode的调试终端调试项目,因为用chrome调试不能打断点。

我在使用 vscode 和 RN 方面还很陌生,请更详细地解释可能的解决方案。

提前致谢。

克里斯

最佳答案

错误在 vscode-react-native 扩展中。已经有一个 pull request旨在解决此问题,但如果您喜欢冒险,请转到您的 vscode 扩展文件夹,打开 vscode-react-native 文件夹,转到 src/debugger/forkedAppWorker.js 并替换以下行:

const nodeArgs = [`--inspect=${port}`, "--debug-brk", scriptToRunPath]; 

const nodeArgs = [`--inspect=${port}`, "--debug-brk"];

this.debuggeeProcess = child_process.spawn("node", nodeArgs, { 
stdio: ["pipe", "pipe", "pipe", "ipc"],
})

this.debuggeeProcess = child_process.fork(scriptToRunPath, nodeArgs) 

有关详细信息,请参阅 actual file change log (不要担心它是 .ts 还是 .js,也不要担心其他两个文件被更改)。

关于android - 调试适配器 : SyntaxError: Unexpected token L in JSON at position 0 中未处理的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51359720/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com