To use VSCode debugger with a custom version of Node.js, we can use node.js
bash script to run the correct version using nvm
.
#!/bin/bash
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
nvm run $*
chmod +x node.sh
4
{
"type": "node",
"request": "launch",
"name": "Launch program",
"program": "${workspaceRoot}/index",
"runtimeExecutable": "${workspaceRoot}/node.sh",
"protocol": "legacy"
}
this is enough if NVM_DIR
is exported, which it should be.
make sure to specify legacy protocol for Node 4.