简体   繁体   中英

How to remotely debug Node.js app with source maps (using WebStorm)

I struggling to debug remotely piece of node.js code that got translated from ES6 with BabelJs. Here's the situation:

I have a project with ES6 source file server\\app.js that gets translated to ES5 and put to dist\\server\\app.js along with dist\\server\\app.js.map . I can set a breakpoint in original server\\app.js and then debug locally file dist\\server\\app.js to hit that breakpoint - source map works perfectly fine.

Now I have put my entire dist folder to remote PC where I start my app with node --debug-brk dist\\server\\app.js command. Connecting to that process with remote debugger from WebStorm makes the application run, but the breakpoint is not hit.

Surprisingly, if I run node --debug-brk dist\\server\\app.js from terminal on the same host where my WebStorm is installed, then remote debugger connecting to localhost:5858 is able to trigger that breakpoint.

Is there anything that I am missing in order to hit that breakpoint when debugging remotely?

Thanks in advance for any suggestions.

Webstorm: 2016.1
Node: 4.4.2 (both local and remote machine)

When a breakpoint is hit in the communication with WebStorm node debugger seems to send line number and filename. File path is the the path from the server node is running on. What we have is:

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).

What node is sending back is this path:

/remotePath/dist/server/app.js

So WebStorm tries to find this file in its file system. But it doesn't exist. The solution here could be to create a symbolic link in the local file system:

/remotePath -> /localPath

Btw. VS Code has it solved by exposing localRoot and remoteRoot in debug configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM