vscode-js-debug
vscode-js-debug copied to clipboard
Support nodenv in the nvm resolver or binary provider
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:
- Install nodenv
- Make your default node version >= 12.x
- Make an app that uses a
.node-versionfile to use 10.x for it - Make a launch config to debug this app
- Try to debug it. It fails because it's trying to use the node 12.x
--inspect-publish-uidflag 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.
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.
Fyi there was a bug in the binary provider, you'll need to use the next nightly for the hint to work.
A workaround for you is to add
nodeVersionHint: 10to your package.json
I think you meant to add it to launch.json?
yes, fixed