Last active
March 28, 2023 12:44
-
-
Save itsjavi/53eb4da9d7ad3d05f9ff0417726b2081 to your computer and use it in GitHub Desktop.
Switch node version in the current zsh session, depending on an env var
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
export N_SESSION_NODE_VERSION=18 | |
# Then, in your PHPStorm or Webstorm project settings you can configure the | |
# Terminal to override this value via N_SESSION_NODE_VERSION_OVERRIDE, e.g.: | |
# N_SESSION_NODE_VERSION_OVERRIDE=16 | |
# |
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
export N_NODE_VERSION=${N_SESSION_NODE_VERSION_OVERRIDE:-$N_SESSION_NODE_VERSION} | |
if [[ $(node --version) == "v$N_NODE_VERSION"* ]]; then | |
echo "Current node version is: $(node --version). N_SESSION_NODE_VERSION=${N_NODE_VERSION}" | |
else | |
echo "Switching node version to '${N_NODE_VERSION}'" | |
n "${N_NODE_VERSION}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment