简体   繁体   English

WebStorm Node.js远程调试是否与Docker容器中的Node.js v8一起使用?

[英]Does WebStorm Node.js Remote Debug work with Node.js v8 in Docker container?

Using chrome://inspect I can access 0.0.0.0:56745 to do debugging, 使用chrome://inspect我可以访问0.0.0.0:56745进行调试,

在此输入图像描述

But I find debugging in WebStorm a far better experience. 但我发现在WebStorm中调试是一种更好的体验。 I try to create a Node.js Remote Debug configuration like this to see if WebStorm supports it: 我尝试创建这样的Node.js Remote Debug配置,以查看WebStorm是否支持它:

在此输入图像描述

There's no response to any breakpoints in the js files. 对js文件中的任何断点都没有响应。

Can you tell me whether WebStorm supports debugging Docker node inside WebStorm (not via Chrome developer tool) in the latest 2017.2.5 version? 您能否告诉我WebStorm是否支持在最新的2017.2.5版本中调试WebStorm内的Docker节点(而不是通过Chrome开发人员工具)?

docker-compose.yml 泊坞窗,compose.yml

version: '3'
services:
  web:
    build:
      context: .
      dockerfile: docker/DockerfileDev.df
    image: web:dev
    ports:
      - "3000:3000"
      - "0.0.0.0:56745:56745"
    expose:
      - "56745"
    entrypoint: ["npm", "run","nodemon" ]

package.json: 的package.json:

  "scripts": {
    "nodemon": "./node_modules/nodemon/bin/nodemon.js --inspect=0.0.0.0:56745 --debug-brk index.js"
  },

DockerfileDev.df DockerfileDev.df

  FROM node:8
  # some other stuff

UPDATE UPDATE

The Remote debugger shows it's connecting, but there's nothing in the console, and doesn't pause at breakpoints: 远程调试器显示它正在连接,但控制台中没有任何内容,并且不会在断点处暂停:

在此输入图像描述

Node.js Remote run configuration can only be used when debugging with TCP-based Protocol (Node.js < 7.x). Node.js远程运行配置只能在使用基于TCP的协议(Node.js <7.x)进行调试时使用。

To remotely debug application with Chrome Debugging Protocol (with --inspect / --inspect-brk , Node.js 7+), you need using Chromium Remote run configuration 要使用Chrome调试协议远程调试应用程序(使用--inspect / --inspect-brk ,Node.js 7+),您需要使用Chromium Remote运行配置

After spending days trying to figure out what the problem was, I found that I needed to set the remote debug host to: localhost 花了好几天试图找出问题所在,我发现我需要将远程调试主机设置为: localhost

then, make sure to update the "default" machine in Virtual Box to forward port: 56745 (NAT) 然后,确保更新Virtual Box中的“默认”机器以转发端口:56745(NAT)

This way, I figured, webstorm connects to the container debugger through your host machine. 通过这种方式,我认为,webstorm通过主机连接到容器调试器。 At least that's the way I got Nodejs v8 to work. 至少那是我让Nodejs v8工作的方式。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM