[英]Breakpoint set but not yet bound in Visual Studio Code for a dockerized node process
我正在嘗試將 macOS Catalina 上的 Visual Studio Code 中的調試器用於節點應用程序。 我創建了一個非常簡單的例子來說明我的情況。
索引.js
require('http').createServer( (request, response) => {
response.writeHead(200, {'Content-Type': 'text/plain'})
response.end('Hello World\n');
response.end();
}).listen(3000);
文件
FROM node:12.14.0-alpine
COPY . /src
CMD ["node","--inspect=0.0.0.0", "src/index.js"]
我構建了 Dockerfile
docker build . -t debugtest
然后運行它
docker run -p 3000:3000 -p 9229:9229 debugtest
我可以訪問http://localhost:3000/ 。
我在 index.js 中設置了一個斷點。
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229,
"skipFiles": [
"<node_internals>/**"
]
}
]
}
現在,當我以可視化代碼啟動調試器時,斷點的紅點消失,並出現“斷點設置但尚未綁定”。
我在各個地方都看到過這個問題,但沒有一個解決方案有效。 當我在node --inspect index.js
之外運行節點進程時,它可以順利運行。
我使用的是 1.41.1 版的 Visual Studio 代碼和 docker 2.1.0.5。
原來我在launch.json
省略了remoteRoot
屬性。 下面的作品。
啟動文件
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229,
"remoteRoot": "/src/",
"skipFiles": [
"<node_internals>/**"
]
}
]
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.