Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm update -g does nothing even though I have outdated packages

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
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]

>

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 [email protected]
>

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?

like image 741
Klas Mellbourn Avatar asked Feb 19 '16 15:02

Klas Mellbourn


People also ask

Can npm detect outdated packages?

Description. This command will check the registry to see if any (or, specific) installed packages are currently outdated. By default, only the direct dependencies of the root project and direct dependencies of your configured workspaces are shown.

Does npm update packages automatically?

Run npm update to automatically update my packages to the latest versions From docs: > This command will update all the packages listed to the latest version (specified by the tag config), respecting the semver constraints of both your package and its dependencies (if they also require the same package).

Does npm install update package versions?

The npm install installs all modules that are listed on package. json file and their dependencies. npm update updates all packages in the node_modules directory and their dependencies.


1 Answers

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
like image 109
mjs Avatar answered Oct 04 '22 02:10

mjs