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

时间:2017-11-16 05:40:21

标签: node.js docker docker-compose webstorm

使用chrome://inspect我可以访问0.0.0.0:56745进行调试,

enter image description here

但我发现在WebStorm中进行调试是一种更好的体验。我尝试创建这样的Node.js Remote Debug配置,以查看WebStorm是否支持它:

enter image description here

对js文件中的任何断点都没有响应。

您能告诉我WebStorm是否支持在最新的2017.2.5版本中调试WebStorm内的Docker节点(不是通过Chrome开发人员工具)?

搬运工-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:

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

DockerfileDev.df

  FROM node:8
  # some other stuff

更新

远程调试器显示它正在连接,但控制台中没有任何内容,并且不会在断点处暂停:

enter image description here

2 个答案:

答案 0 :(得分:3)

Node.js Remote运行配置只能在使用基于TCP的协议(Node.js< 7.x)进行调试时使用。

要使用Chrome调试协议远程调试应用程序(使用--inspect / --inspect-brk,Node.js 7+),您需要使用Chromium Remote运行配置

答案 1 :(得分:0)

花了几天的时间试图找出问题所在之后,我发现我需要将远程调试主机设置为: 本地主机

然后,确保将Virtual Box中的“默认”计算机更新为转发端口: 56745(NAT)

我认为这样,webstorm通过您的主机连接到了容器调试器。至少那是我让Nodejs v8正常工作的方式。

祝你好运!