Created
September 20, 2014 19:36
-
-
Save othiym23/4ac31155da23962afd0e to your computer and use it in GitHub Desktop.
a safe way to upgrade all of your globally-installed npm packages
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/sh | |
set -e | |
set -x | |
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3) | |
do | |
npm -g install "$package" | |
done |
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/sh | |
set -e | |
set -x | |
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f2) | |
do | |
npm -g install "$package" | |
done |
If you prefer to choose which global modules are updated I've added interactive updating to npm-check with support for
global
.It also includes links to the source for each updated package so you can find out what's new.
Behind the scenes
npm-check
usesnpm install
thanks to the recommendation from @othiym23 in this thread.# install npm -g i npm-check # interactive update of global packages npm-check -u -g # interactive update for a project you are working on npm-check -uSource: github.com/dylang/npm-check
Great, bro! Thanks! :D
The Wanted
version shall be another major version, which is not very favorable, since it can break things.
Here is a way to upgrade only minor versions of global packages:
npm_global_packages=($(npm list -g --depth 0 | awk '/ /{print $2}'))
for val in "${npm_global_packages[@]}"; do
npm i -g --force $(echo $val | tr "." "\n" | head -1)
done
Good part is, that it will not bump npm
to a version that is incompatible with the current node
version, so this will most likely not break.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running npm v6.8.0 and seeing this problem again. Global packages won't update beyond "wanted".