【问题标题】:How to change node.js debug port?如何更改 node.js 调试端口?
【发布时间】:2018-03-18 05:37:51
【问题描述】:

例如,如何将其从 5858 更改为 7000?

【问题讨论】:

    标签: node.js debugging


    【解决方案1】:

    您可以使用--debug 选项:

    node --debug=7000 app.js
    

    您可以为最新节点使用--inspect 选项>= v8

    node --inspect=7000 app.js
    

    https://nodejs.org/en/docs/inspector/

    【讨论】:

    • 这在让 Grunt 运行多个并发任务并且仍然让它们同时调试时非常有用。
    • 同样的语法适用于 nodemon,因为它将参数传递给 node。
    【解决方案2】:

    对于 nodejs 版本 >= v8 使用这个:

    node --inspect=7000 --inspect-brk app.js
    

    【讨论】:

    • 我相信至少早在节点 v6 时就是这种情况。 (但不是 v4。)
    【解决方案3】:

    在 unix 命令行中试试这个

     $ PORT=7000 node --debug app.js
    

    【讨论】:

      猜你喜欢
      • 2017-05-09
      • 2012-08-24
      • 1970-01-01
      • 2018-05-12
      • 1970-01-01
      • 2015-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多