- Create a variant of the
nvm-execscript which does not fail if there is no.nvmrcpresent. I called itnvm-exec-2(see below). - Place that script inside the
.nvmdirectory in your user's home directory (~/.nvm) and make it executable:chmod +x ~/.nvm/nvm-exec-2 - Modify the "profiles" of the integrated terminal of VSCode in the
settings.json. The keys of the corresponding settings are:-
For the "automationProfile" - this is the terminal used when running "tasks" or when debugging:
terminal.integrated.automationProfile.osxterminal.integrated.automationProfile.windowsterminal.integrated.automationProfile.linux
Set those to:
"terminal.integrated.automationProfile.<your OS>": { "path": "/<path to your user home>/.nvm/nvm-exec-2", "args": ["<your shell>"], }
so for example on my machine:
"terminal.integrated.automationProfile.osx": { "path": "/Users/julrich/.nvm/nvm-exec-2", "args": ["zsh"], }
-
For the regular terminal profiles:
terminal.integrated.profiles.osxterminal.integrated.profiles.windowsterminal.integrated.profiles.linux
There you can define multiple profiles in case you have multiple shells available on your machine. Again, use
<path to user home>/.nvm/nvm-exec-2as thepathfor the shell and provide the actual shell command viaargs. For example:"terminal.integrated.profiles.osx": { "zsh": { "path": "/Users/julrich/.nvm/nvm-exec-2", "args": ["zsh", "-l"], }, "bash": { "path": "/Users/julrich/.nvm/nvm-exec-2", "args": ["bash", "-l"], "icon": "terminal-bash", }, }
-
Last active
February 17, 2026 12:09
-
-
Save j-ulrich/f35c461cf0b321bb35df0f90c6286a70 to your computer and use it in GitHub Desktop.
Integrating nvm (https://github.com/nvm-sh/nvm) and Visual Studio Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
| unset NVM_CD_FLAGS | |
| # shellcheck disable=SC1090,SC1091 | |
| \. "$DIR/nvm.sh" --no-use | |
| if [ -n "$NODE_VERSION" ]; then | |
| nvm use "$NODE_VERSION" > /dev/null || exit 127 | |
| else | |
| nvm use >/dev/null 2>&1 || true | |
| fi | |
| exec "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment