【應用SSR-nuxt開發日記2】新版vscode調試問題

之前用的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

睡覺?? 搞完它 我們再研究下細節

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容