vscode-js-debug icon indicating copy to clipboard operation
vscode-js-debug copied to clipboard

Support nodenv in the nvm resolver or binary provider

Open mgabeler-lee-6rs opened this issue 5 years ago • 4 comments

Describe the bug I can no longer debug apps that don't use at least node12, when using nodenv

To Reproduce Steps to reproduce the behavior:

  1. Install nodenv
  2. Make your default node version >= 12.x
  3. Make an app that uses a .node-version file to use 10.x for it
  4. Make a launch config to debug this app
  5. Try to debug it. It fails because it's trying to use the node 12.x --inspect-publish-uid flag with node 10

VS Code Version: 1.49.0

Additional context The problem seems to be that the feature enabled in https://github.com/microsoft/vscode-js-debug/commit/32244ec6b0c979f79a1808cbb506e6ef5900d6b2 relies on resolveAndValidate here https://github.com/microsoft/vscode-js-debug/blob/2518eeb26140ef2d3c0254056614bf335b7a29d3/src/targets/node/nodeBinaryProvider.ts#L128 And that code doesn't understand that the node binary in use may depend on the working directory, not just PATH from the environment.

mgabeler-lee-6rs avatar Sep 17 '20 20:09 mgabeler-lee-6rs

A workaround for you is to add nodeVersionHint: 10 to your launch.json. A more correct fix would be to support nodenv in the NvmResolver (todo: should be refactored to be a little more modular) or NodeBinaryProvider to resolve the binary statically there.

connor4312 avatar Sep 17 '20 20:09 connor4312

Fyi there was a bug in the binary provider, you'll need to use the next nightly for the hint to work.

connor4312 avatar Sep 17 '20 20:09 connor4312

A workaround for you is to add nodeVersionHint: 10 to your package.json

I think you meant to add it to launch.json?

mgabeler-lee-6rs avatar Nov 19 '20 21:11 mgabeler-lee-6rs

yes, fixed

connor4312 avatar Nov 19 '20 21:11 connor4312