-
-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nvm use
in vscode, run npm script
and switch node versions automatically
#3385
Comments
~/.zshrc export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local nvmrc_path
nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
nvm install
elif [ "$nvmrc_node_version" != "$(nvm version)" ]; then
nvm use
fi
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc |
Is "npm scripts" a feature built into vscode, or a plugin? Either way I think you need to file an issue there; if the vscode terminal is correct, then anything that launches a program should start in that terminal, and also be correct. Even the autoload scripts aren't part of nvm; you're kind of on your own when you choose to use them. |
got it |
sorry,again。 |
@vanchKong gotcha, that means that the "run script" command isn't starting a login shell. It's still something you should file with vscode or the extension. |
Operating system and version:
nvm debug
output:nvm ls
output:How did you install
nvm
?install script in readme
What steps did you perform?
~/.zshrc
has command to automatically switch node versions.nvmrc
file in the project, containing the non-default version12
What happened?
run
in thenpm script
that comes with vscode, and the default node version is still usedWhat did you expect to happen?
run
in thenpm script
that comes with vscode, and the node version switch automaticallyIs there anything in any of your profile files that modifies the
PATH
?no
The text was updated successfully, but these errors were encountered: