Skip to content

Instantly share code, notes, and snippets.

@yuhui
Last active May 16, 2025 10:33
Show Gist options
  • Save yuhui/b0821c4c8838b467e9bbb88213e58594 to your computer and use it in GitHub Desktop.
Save yuhui/b0821c4c8838b467e9bbb88213e58594 to your computer and use it in GitHub Desktop.
Update NodeJS' node (using nvm) and npm
#!/bin/zsh
# source NVM
. ~/.nvm/nvm.sh
echo "$ nvm cache clear"
nvm cache clear
echo "$ nvm install 'lts/*' --reinstall-packages-from=current --latest-npm"
nvm install 'lts/*' --reinstall-packages-from=current --latest-npm
. ~/.nvm/nvm.sh
echo "$ npm cache clear"
npm cache clear --force
echo "$ npm update -g"
npm update -g
echo "$ npm install -g npm-check-updates"
npm i -g npm-check-updates
echo "$ npm prune"
npm prune
echo "$ npm doctor"
npm doctor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment