Nvm does not work in vscode tasks, because tasks are run without a shell. .bashrc
is not loaded and the nvm command is unknown.
My solution uses a wrapper script around /bin/bash
that reads in the correct node version from .npmrc
in the project folder.
#!/bin/bash
set -e
if [[ "$2" == nvm* ]]; then
export NODE_VERSION=v$(cat .nvmrc)