WebStorm NPMdebuggingconfiguration中的“拒绝连接”

考虑到我对debugging器真正做的事情只有最松散的理解,我需要帮助为express.js应用程序设置WebStorm npmdebuggingconfiguration。

这是我至今 – 我点击我的设置debugging,因为我认为他们应该(下):

 /Users/me/.nvm/versions/node/v4.4.1/bin/node --debug=8090 /Users/me/.nvm/versions/node/v4.4.1/lib/node_modules/npm/bin/npm-cli.js run-script start To debug "start" script, make sure $NODE_DEBUG_OPTION string is specified as the first argument for node command you'd like to debug. For example: { "start": "node $NODE_DEBUG_OPTION server.js" } Debugger listening on port 8090 ... It has begun. Port: 3000 

所以在这一点上,应用程序已经启动并响应我的POSTlocalhost:3000 ,但不会中断我设置的断点。

在debugging器>variables窗格中,我看到Connecting to localhost:57617 ,然后popup一个工具提示说“连接被拒绝”,窗格中说Frame is not available

我不明白57617的端口号是从哪里来的。 虽然不是根据我发现的任何模式,但它总是不同于我在--debug=X--debug-brk=X节点选项中设置的模式。

错误信息确实很不清楚。 你需要调整package.json中的npm脚本条目(不幸的是)。 在此博客文章中find明确的描述: http : //pavelpolyakov.com/2016/05/01/webstorm-npm-tasks-debug/

您的start条目应如下所示:

 "scripts": { "start": "node $NODE_DEBUG_OPTION ./node_modules/someModule/bin/someModule.js --arguments" } 

你也可以去两个条目,以保持第一个干。 虽然从命令行运行得都不错,但并不是必须的。 为了完整起见,

 "scripts": { "start": "someModule --arguments", "startDebug": "node $NODE_DEBUG_OPTION ./node_modules/someModule/bin/someModule.js --arguments" } 

我不觉得这个方法特别干净,imo这是npmdebugging器应该为你做的,而不必操纵源代码。 但似乎是唯一的方法(现在)。

在以前版本的Node或Webstorm中我从来不需要这个。 不知道现在需要更改哪个选项。

我不得不将它添加到package.json ,但是将它添加到运行configuration不起作用。 而且我不得不制作一个单独的脚本,因为在没有debugging的情况下运行任何脚本时都会中断。

这里是我的package.json( 注意Windows样式variables%VAR%,对于类Unix系统使用$ VAR ):

 "scripts": { "start": "node index.js", "debug": "node %NODE_DEBUG_OPTION% index.js", }, 

然后,当我想要debugging时,我使用一个调用debugging选项的运行configuration – 因为在Windows中至less有一个节点,当它没有被replace时,它会逐字地取出variables。


如果您尝试在Webstorm(2016.3.3)运行configuration对话框中inputvariables:

Webstorm运行配置

它导致这些实际的命令,这是不正确的:

作为一个脚本参数:

"C:\...\runnerw.exe" "C:\...\node.exe" "C:\...\npm-cli.js" run start %NODE_DEBUG_OPTION%

作为节点选项:

"C:\...\runnerw.exe" "C:\...\node.exe" %NODE_DEBUG_OPTION% "C:\...\npm-cli.js" run start

但是,似乎需要将选项传递给NPM,而不是npm脚本(前者),而不是节点(后者),而且据我所知,在对话框中没有办法做到这一点。 因此,添加到package.json脚本命令。