我努力远程调试从Bab6Js用ES6翻译的一段node.js代码。情况如下:
我有一个ES6源文件functions = []
for n in [1, 2, 3]:
def func(x):
return n*x
functions.append(func)
# You would expect this to print [2, 4, 6]
print(
'calling a list of bad closures and output is: {}'
.format(str([function(2) for function in functions]))
)
的项目,该项目已转换为ES5并与server\app.js
一起放入dist\server\app.js
。我可以在原始dist\server\app.js.map
中设置断点,然后调试本地文件server\app.js
以达到该断点 - 源映射完全正常。
现在我将整个dist\server\app.js
文件夹放到远程PC上,用dist
命令启动我的应用程序。使用WebStorm中的远程调试器连接到该进程会使应用程序运行,但断点不会被命中。
令人惊讶的是,如果我从安装了我的WebStorm的同一主机上的终端运行node --debug-brk dist\server\app.js
,那么连接到localhost:5858的远程调试器就能够触发该断点。
为了在远程调试时遇到该断点,我有什么遗漏吗?
提前感谢任何建议。
node --debug-brk dist\server\app.js
答案 0 :(得分:1)
当在与WebStorm节点的通信中遇到断点时,调试器似乎发送行号和文件名。文件路径是运行服务器节点的路径。我们拥有的是:
Server (remote):
/remotePath/dist/server/app.js (transpiled file ES5)
Local system:
/localPath/server/app.js (source file ES6)
/localPath/dist/server/app.js (transpiled file ES5)
/localPath/dist/server/app.js.map (source map).
回送的节点是这条路径:
/remotePath/dist/server/app.js
因此,WebStorm尝试在其文件系统中查找此文件。但它并不存在。 这里的解决方案可能是在本地文件系统中创建一个符号链接:
/remotePath -> /localPath
顺便说一下。 VS Code通过在调试配置中公开localRoot和remoteRoot来解决它。