IntelliJ IDEA如何正确将$ NODE_DEBUG_OPTION传递给npm-run-all [英] IntelliJ IDEA how to correctly pass $NODE_DEBUG_OPTION to npm-run-all

查看:1500
本文介绍了IntelliJ IDEA如何正确将$ NODE_DEBUG_OPTION传递给npm-run-all的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Ubuntu 16.04 上,我使用 IntelliJ IDEA ultima 2017.2 node v6.11.2 npm v3.10.10 和 要调试一个node.js应用程序,该应用程序具有以下 package.json 开始条目:

On my Ubuntu 16.04 I use IntelliJ IDEA ultima 2017.2 together with node v6.11.2 and npm v3.10.10 and want to debug a node.js application, which has the following package.json start entry:

"start:" "npm-run-all --parallel serve-static open-static"

根据控制台输出和这个类似的问题需要添加 $ NODE_DEBUG_OPTION 作为第一个参数(用于节点),以避免出现拒绝连接错误. Obvioulsy,我尝试过

According to the console output and this similar SO question I need to add $NODE_DEBUG_OPTION as first parameter (for node) to avoid the Connection refused error. Obvioulsy, I have tried

  • 在运行/调试"配置中将$ NODE_DEBUG_OPTION添加为参数
  • 和作为节点选项
  • to add $NODE_DEBUG_OPTION in the Run/Debug configuration as Arguments
  • and as Node options

导致了

node npm-cli.js run start-debug --scripts-prepend-node-path=auto $NODE_DEBUG_OPTION

node $NODE_DEBUG_OPTION npm-cli.js run start-debug --scripts-prepend-node-path=auto 

在每种情况下,$ NODE_DEBUG_OPTION均无法解析,并且 node 将其视为不存在的文件.

in each case $NODE_DEBUG_OPTION is not resolved and node treats it like a non-existing file.

我也试图像

    "start:" "npm-run-all $NODE_DEBUG_OPTION --parallel serve-static open-static"

这还会导致找不到模块.../$ NODE_DEBUG_OPTION 错误.

那么,如何在IntelliJ IDEA中调试该选项呢?

So, how can I pass this option in order to debug that thingy in IntelliJ IDEA?

谢谢

推荐答案

手动将$NODE_DEBUG_OPTION添加到package.json是调试通过npm脚本启动的应用程序的唯一方法,因为您必须确保Node.js是使用适当的调试选项(--debug-brk--inspect-brk等)启动,并且IDE无法控制生成子进程的方式-它只能在启动主进程时将选项传递给主进程.但是必须将此选项传递给Node.js,而不是 npm-cli.js npm-run-all 等.如果 npm-run- all 是一个npm脚本,用于启动要使用node.js调试的应用程序,您需要相应地修改此脚本,例如:

adding $NODE_DEBUG_OPTION to package.json manually is the only way to debug the application started via npm script, because you have to make sure that Node.js is started with appropriate debug options (--debug-brk, --inspect-brk, etc), and the IDE can't control the way child processes are spawned - it can only pass options to the main process when starting it. But this option has to be passed to Node.js - not to npm-cli.js, npm-run-all, etc. If npm-run-all is an npm script that starts the app you'd like to debug with node.js, you need to modify this script accordingly, like:

"npm-run-all": "node $NODE_DEBUG_OPTION myapp.js" 

如果您的任务运行一个Shell脚本,而该脚本随后又使用node.js运行您的应用程序,则您需要修改一个Shell脚本...目标是使用调试选项启动节点进程

If your task runs a shell script, that, in turn, runs your app with node.js, you need to modify a shell script... The goal is to start the node process with debug options

这篇关于IntelliJ IDEA如何正确将$ NODE_DEBUG_OPTION传递给npm-run-all的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆