npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

npm warns about new version while installing new npm version

What I Wanted to Do

After updating npm from v6.1.0 to v6.2.0, I was shown a banner that there is a new version of npm available, that version being the one I had just installed.
Command run: npm install -g npm

What Happened Instead

I was presented with this output at the completion of the npm install... command:

   │                                                               │          
   │      New minor version of npm available! 6.1.0 -> 6.2.0       │          
   │   Changelog:   │          
   │               Run npm install -g npm to update!               │          
   │                                                               │          

Reproduction Steps


  1. Run the command npm outdated -g
  2. Make sure that there is a newer version of the NPM package available in the list
  3. Run the command npm install -g npm
  4. Wait for command to complete


It would seem logical that, instead of displaying the banner after installing the newer version of NPM, it be displayed either when a) completing the execution of the npm outdated [-g] command, or b) after each execution of an npm install [-g] command if the install did not include the NPM package.

Platform Info

$ npm --versions
{ npm: '6.2.0',
  ares: '1.10.1-DEV',
  cldr: '31.0.1',
  http_parser: '2.7.0',
  icu: '59.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.7.0',
  openssl: '1.0.2l',
  tz: '2017b',
  unicode: '9.0',
  uv: '1.15.0',
  v8: '6.1.534.42',
  zlib: '1.2.11' }

$ node -p process.platform

ugh. I thought I’d fixed this. The bug exists somewhere in here:

I would love a patch from someone interested in fixing this for us. A protip for devving on this is that you can pass a updateCheckInterval: 0 as an option to update-notifier to make it so it will always show you the update notifier.

I was taking a look at this and wondering if the check should happen after npm is done installing. This way, if we are in fact updating npm itself, we are only checking after that update is complete. Alternatively, we could check to see if the update is for npm itself, but that sounds unnecessarily special-cased.

I think I was able to test this appropriately (thanks for the hint on updateCheckInterval). I’m still working on locating an appropriate test to modify (or create a new one).

EDIT: I just found this, so maybe no test? YOLO :wink:

It looks like pnpm (as referenced in the above commit) doesn’t check for updates when updating itself. See:

I will make a PR that does the same

PR is here: