npm outdated -g fail with Cannot read property 'length' of undefined

What I Wanted to Do

Run npm outdated -g with npm@6.9.0. I have an outdated global typescript version.

What Happened Instead

The command failed with Cannot read property 'length' of undefined.

Reproduction Steps

  1. Install an older typescript version, e.g npm install -g typescript@3.2.4.
  2. Run npm outdated -g.

Skip step 1 if you already have a non-latest version of typescript installed globally.

Details

I can confirm npm@6.8.0 does not have this bug.

Error log:

 27 http fetch GET 304 https://registry.npmjs.org/typescript 259ms (from cache)
 28 silly pacote registry packument for typescript@^3.2.4 fetched in 285ms
 29 verbose stack TypeError: Cannot read property 'length' of undefined
 29 verbose stack     at dotindex (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:59:32)
 29 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/text-table/index.js:11:21
 29 verbose stack     at Array.forEach (<anonymous>)
 29 verbose stack     at forEach (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:73:31)
 29 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/text-table/index.js:10:9
 29 verbose stack     at Array.reduce (<anonymous>)
 29 verbose stack     at reduce (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:63:30)
 29 verbose stack     at module.exports (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:9:20)
 29 verbose stack     at /usr/local/lib/node_modules/npm/lib/outdated.js:130:16
 29 verbose stack     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
 29 verbose stack     at doIt (/usr/local/lib/node_modules/npm/lib/outdated.js:381:14)
 29 verbose stack     at updateDeps (/usr/local/lib/node_modules/npm/lib/outdated.js:443:9)
 29 verbose stack     at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
 29 verbose stack     at Promise.successAdapter [as _fulfillmentHandler0] (/usr/local/lib/node_modules/npm/           node_modules/bluebird/js/release/nodeify.js:23:30)
 29 verbose stack     at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/    promise.js:566:21)
 29 verbose stack     at Promise._settlePromise0 (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/   promise.js:614:10)

Platform Info

$ npm --versions
{ npm: '6.9.0',
  ares: '1.15.0',
  brotli: '1.0.7',
  cldr: '34.0',
  http_parser: '2.8.0',
  icu: '63.1',
  llhttp: '1.1.1',
  modules: '67',
  napi: '4',
  nghttp2: '1.34.0',
  node: '11.11.0',
  openssl: '1.1.1a',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.26.0',
  v8: '7.0.276.38-node.18',
  zlib: '1.2.11' }
$ node -p process.platform
darwin

(Looks like same stack as 'npm outdated' throw an error (Cannot read property 'length' of undefined) )

1 Like

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