17

I am running npm version 3.6.0 and node verison 5.6.0 on Windows 10:

> npm version
{ npm: '3.6.0',
  ares: '1.10.1-DEV',
  http_parser: '2.6.1',
  icu: '56.1',
  modules: '47',
  node: '5.6.0',
  openssl: '1.0.2f',
  uv: '1.8.0',
  v8: '4.6.85.31',
  zlib: '1.2.8' }
>

I have a number of globally installed npm packages:

> npm ls -g --depth=0
C:\Users\Klas\AppData\Roaming\npm
+-- bower@1.7.7
+-- generator-gulp-angular@1.0.2
+-- generator-gulp-angular-subtask@0.9.1
+-- gulp@3.9.1
+-- jspm@0.16.25
+-- karma-cli@0.1.2
+-- live-server@0.9.0
+-- protractor@3.0.0
+-- tsd@0.6.5
+-- tslint@3.2.2
+-- typescript@1.7.5
+-- webpack@1.12.11
+-- webpack-dev-server@1.14.1
`-- yo@1.6.0

>

If I run npm outdated -g several packages are listed as outdated.

> npm outdated -g
Package      Current   Wanted   Latest  Location
jspm         0.16.25  0.16.25  0.16.29
live-server    0.9.0    0.9.0    0.9.2
protractor     3.0.0    3.0.0    3.1.1
tslint         3.2.2    3.2.2    3.4.0
webpack      1.12.11  1.12.11  1.12.13

When I run npm update -g it returns (after a couple of seconds) without any warning or error message. However, no packages have been updated.

> npm update -g
>

As I interpret this issue, npm update -g should work, and should update top level global packages. But it doesn't seem to work for me.

If I run (thanks to Benjamin Kaiser for the tip):

> npm update -g --loglevel verbose

I get a lot of output. This seems to be the most relevant:

npm verb outdated not updating tslint because it's currently at the maximum version 
that matches its specified semver range

I still don't quite understand. Since the packages are global, there is no specified semver range?

Running update on a particular package does not help either:

> npm update -g tslint
>

Not even specifying a version does any difference:

> npm update -g tslint@3.4.0
>

But even if that had worked I would rather not have to explicitly update each package. To me, a major feature of a package manager should be to make it easy to update everything at once.

This issue sounds related. But when I look at the tslint npm module the "latest" seems to be 3.4.0. So why no upgrade?

Klas Mellbourn
  • 42,571
  • 24
  • 140
  • 158
  • 1
    Have you tried adding the `--loglevel verbose` flag to see if anything might be happening at a lower log level? From everything you've said, your npm version should be up to date to run that command. – Benjamin Kaiser Feb 19 '16 at 19:27
  • Thanks @BenjaminKaiser, I extended my question with the results of setting that flag – Klas Mellbourn Feb 19 '16 at 21:26
  • 1
    That's super weird, you are right that it's global and as such shouldn't have a semver. I'd maybe try wiping global packages an starting again. Maybe reinstalling npm also to the latest version (3.7.4 I think) – Benjamin Kaiser Feb 19 '16 at 22:14
  • I second that. Looking through this, I've had similar issues and I've wiped and started over as well. – Dave Voyles Feb 21 '16 at 16:36

1 Answers1

13

npm -g update has, uh, pretty unexpected behaviour. This might be a suitable workaround:

$ npm -g outdated --parseable=true | cut -d : -f 4 | xargs -n 1 npm -g install
mjs
  • 63,493
  • 27
  • 91
  • 122
  • Thanks - this is a good workaround, and definitely does the same behaviour that I expect from `npm -g update`. – lantrix Jan 03 '17 at 08:24
  • 4
    This answer could be greatly improved by elaborating what is `npm` behavior, what are implications of it and whether there is any way of changing it. Right now we have command that does fix the problem, but no real understanding of the issue. – Mirek Długosz Apr 01 '18 at 08:51