Created
September 9, 2021 15:45
-
-
Save shepherd44/5b63769dffc1a29403b12dc234c7fd40 to your computer and use it in GitHub Desktop.
npm update script(with git bash on windows)
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
#!/bin/bash | |
npm_version=$(npm --version) | |
npm_path=$(which npm) | |
npm_dirname=$(dirname $npm_path) | |
echo current npm version: $npm_version | |
echo current npm dirpath: $npm_dirname | |
cd $npm_dirname | |
test -e npm && mv npm npm-$npm_version | |
test -e npm.ps1 && mv npm.ps1 npm-$npm_version.ps1 | |
test -e npm.cmd && mv npm.cmd npm-$npm_version.cmd | |
test -e npx && mv npx npx-$npm_version | |
test -e npx.ps1 && mv npx.ps1 npx-$npm_version.ps1 | |
test -e npx.cmd && mv npx.cmd npx-$npm_version.cmd | |
cd node_modules | |
mv npm npm-$npm_version | |
cd npm-$npm_version/bin | |
node npm-cli.js install -g npm@latest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment