美文网首页
【应用SSR-nuxt开发日记2】新版vscode调试问题

【应用SSR-nuxt开发日记2】新版vscode调试问题

作者: 懒先森 | 来源:发表于2017-08-21 23:57 被阅读2574次

之前用的debug 配置非常好 手贱升级了一下vscode直接傻逼艹😭
各种connect ECONNREFUSED 10000毫秒 乱遭的报错😭
相信有朋友跟我一样 搜遍了谷歌 有关的issues
最der的是 也是人总有的问题 就是wrong X show Y

本来是因为X报错 但是因为没有细分处理 或者 漏处理 导致 显示成了Y错 
围绕Y错误 去 错误的修正"错误"

没有办法 只能向vscode项目提issues了,很快专门负责反馈的同学就做了标记
过了4-5小时就给出了反馈


image.png

vscode升级,node版本升级 这两个升级带来了debug兼容问题
在node 6.x之前 走的是debug协议 在node6.4之后 改成了inspector协议
vscode本身继承了ide级别的断点调试功能 也就是说它封装对node-debug操作的一系列操作
这就有个问题 就是vscode 有没有对新协议做兼容

在vscode官方文档中protocol明确指出有三个值
分别如图所示


image.png
  • auto 交给程序自己去判断 如果vscode 判断当前node版本>=6.9 就用inspector协议;如果<8.0 就用legacy 再小 就用debug
  • inspector 强制使用inspector 看好上面 对6.9以上才是稳定支持 而且 electron 不支持
  • legacy 强制使用legacy 8.0以下用它非常舒服:-D
    但是 当你去变更协议后 还是特么的报错
    找了无数的issues还是报错 各种报错……
    竟然有哥们去改vscode源码了……😓

这里不吊着大家了,贴出vscode 同学贴出的答复

👨‍🔧‍:If you are using recent versions of node (e.g. 8.x), you must configure both the npm script and VS Code to use the "inspector" protocol (and use the correct port 9229).

👨‍🔧‍:A good way to do this is by relying on the defaults (and do not specify a debug port at all).

👨‍🔧‍:Change the "dev-debug" script in your package.json to this:

   "dev-debug": "node --inspect node_modules/.bin/nuxt",
    and the launch configure to this:

{
      "type": "node",
      "request": "launch",
      "name": "npm run dev",
      "protocol": "inspector,
      "runtimeExecutable": "npm",
      "runtimeArgs": [
        "run",
        "dev-debug"
      ]
}

👨‍🔧‍:Since both are configured for the inspector protocol they will use the correct port 9229 automatically.

👨‍🔧‍:An even easier way to launch nuxt in debug mode is to do everything in the launch config, so there is no need to touch the package.json at all

{
      "type": "node",
      "request": "launch",
      "name": "launch nuxt",
      "protocol": "inspector,
      "program": "${workspaceRoot}/node_modules/.bin/nuxt"
}

👨‍🔧‍:Please let me know if this works.

按照给出的正确指导 按照最后一个进行了配置

👨‍💻‍:[@weinand](https://github.com/weinand) Thank you so much for your help.
👨‍💻‍:According to your tips.It work!
image.png

睡觉😴 搞完它 我们再研究下细节

相关文章

网友评论

      本文标题:【应用SSR-nuxt开发日记2】新版vscode调试问题

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