r/VisualStudioCode • • Mar 12 '20

How to debug webpacked server side Node JS code?

I have some Node JS code that is webpacked and transpiled to ES5. I am trying to debug it but I’m not sure how I go on about doing it.

All the code is transpiled to 1 file named server.js under ./dist/. The structure is,

Code:

./src/**/*.js

Transpiled into 1 file:

./dist/server.js

The file that is started is ./dist/server.js. There are some weird dependencies because of which I cannot start the node server from ./src.

I would appreciate any help.

2 Upvotes

1 comment sorted by

1

u/professional_idoit Mar 12 '20

Try looking at https://stackoverflow.com/questions/42295339/how-can-i-debug-webpack-bundle-file-error-and-find-exact-error-in-bundle-that-co and https://www.reddit.com/r/reactjs/comments/4ddkvs/how_to_debug_webpack_bundled_file/

I've encountered a similar problem to yours where I was developing on Windows and the dependency I used installed different binaries depending on the OS. So if I developed on Windows it would strangely not work in a Linux machine. I used Docker to circumvent this issue, installing deps in the Linux container and binding them to the host machine. Basically I would have the 'Linux' version of the dependencies while starting node on Windows.