Cannot connect to the target at localhost:9222: Could not connect to debug target

Condition

[vscode debugger mode]
[react, nodejs, nextjs]

在vscode debug的launch.json遇到的問題,無法順利連上chrome port

error info

  • Cannot connect to the target at localhost:9222: Could not connect to debug target
  • unable to attach to browser

Solution

網路上的教學都嘗試過了,但沒有實際解決問題,在Chrome一樣無法使用

–remote-debugging-port=9222

這我不管用

在Chrome.exe的Property.target中,加入–remote-debugging-port=9222,或加入%1
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 -- "%1"
reference

改用edge Browser

目前只能先暫時用這個頂著,能夠串到vscode的breakpoint

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "msedge",
      "request": "launch",
      "name": "Launch Edge against localhost",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}"
    }
  ]
}

Other Knowledge

type:“launch” vs. type:“attach”

在launch.json中兩個type的差別
launch是開啟全新的瀏覽器,attach是用既有的連接

Port 9222

Port 9222 用作BrowserRemote Debugging
Using For debugging

“%1” in bat

When used in a command line, script, or batch file, %1 represents a variable or matched string.
%1會print command後的input值

創建 bat file
[bash]

echo Hello %1, it's nice to meet you.

[powershell | cmd]

greet.bat Alice

會print
在这里插入图片描述

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值