Skip to content

Instantly share code, notes, and snippets.

@z-vr
Last active January 1, 2018 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save z-vr/eea0bc260cdccae50ee3de408d9713ad to your computer and use it in GitHub Desktop.
Save z-vr/eea0bc260cdccae50ee3de408d9713ad to your computer and use it in GitHub Desktop.
run vscode with custom version of node.js

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.

node.sh

#!/bin/bash

[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

nvm run $*
chmod +x node.sh

.nvmrc

4

launch.json

{
    "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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment