HTML5, CSS3, jQuery, JSON, Responsive Design...

Michael Brown August 19 2017 09:34:25 PM

I often use the npm-check-updates package to check the whether my npm packages are up to date. Particularly, my globally installed npm packages, such as...well, npm-check-updates itself!!!

It does have one rather annoying limitation though: -u option, which forces the packages to upgrade, only works with locally installed (i.e. at a project level) packages. It won't work for your global packages. So if you issue this command in your terminal (NB: ncu is an alias to npm-check-updates):

ncu -g -u

you'll see this error: ncu cannot upgrade global packages. Run npm install -g [package] to update a global package. This is a pain, because the npm install -g command requires you specify the packages' names, and there might be a few of these. For example, when I just ran ncu-g on my home Mac, it flagged the following packages as out of date:

To update them all, I would have to type out npm install -g followed by the full list of the packages' names. That's a lot of typing and/or copying and pasting to get the package names that I need. So I Googled around to see if there was a way of formatting ncu's output to produce a more update friendly list. This is the command that I found (sorry, I can't remember where now!):

ncu -g | awk '{print $1}' | paste -sd " " -

Issuing the above command gave me straightforward list of packages to update, like so: