npm warns about new version while installing new npm version

cli
help-wanted
good-first-patch
priority:low
triaged

(Hugo Dahl) #1

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: https://github.com/npm/npm/releases/tag/v6.2.0   โ”‚          
   โ”‚               Run npm install -g npm to update!               โ”‚          
   โ”‚                                                               โ”‚          
   โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ          

Reproduction Steps

Pre-requisite

  • Be running a version of NPM which is less than the currently available version
  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

Details

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
win32

(Kat Marchรกn) #2

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.


(Brian Olore) #3

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? https://github.com/npm/cli/commit/834b46ff48ade4ab4e557566c10e83199d8778c6 YOLO :wink:


(Brian Olore) #4

It looks like pnpm (as referenced in the above commit) doesnโ€™t check for updates when updating itself. See: https://github.com/pnpm/pnpm/blob/master/packages/pnpm/src/main.ts#L174

I will make a PR that does the same


(Brian Olore) #5

PR is here: https://github.com/npm/cli/pull/32


(system) #6

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.