Created
April 12, 2021 14:59
-
-
Save malliapi/15ae4f208e6ccaa38527a0b4ea325ab8 to your computer and use it in GitHub Desktop.
Node & NPM Update
This file contains 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
# update node to latest lts version | |
function nvm::update() { | |
local -r current_node_version=$(nvm current) | |
local -r next_node_version=$(nvm version-remote --lts) | |
if [ "$current_node_version" != "$next_node_version" ]; then | |
local -r previous_node_version=$current_node_version | |
nvm install --lts | |
nvm reinstall-packages "$previous_node_version" | |
nvm uninstall "$previous_node_version" | |
nvm cache clear | |
fi | |
nvm --install-latest-npm | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment