I am trying to determine the version status of my npm installed global packages. After running the npm outdated -g --depth=0
in the terminal I receive this error:
JavaScript
x
5
1
npm ERR! Cannot read property 'length' of undefined
2
3
npm ERR! A complete log of this run can be found in:
4
npm ERR! /Users/dangranger/.npm/_logs/2019-03-14T21_58_37_962Z-debug.log
5
Contents of /Users/dangranger/.npm/_logs/2019-03-14T21_58_37_962Z-debug.log
JavaScript
1
59
59
1
0 info it worked if it ends with ok
2
1 verbose cli [ '/usr/local/Cellar/node/11.11.0/bin/node',
3
1 verbose cli '/usr/local/bin/npm',
4
1 verbose cli 'outdated',
5
1 verbose cli '-g' ]
6
2 info using npm@6.9.0
7
3 info using node@v11.11.0
8
4 verbose npm-session 6182351d371bfeb5
9
5 http fetch GET 304 https://registry.npmjs.org/http-server 597ms (from cache)
10
6 silly pacote registry packument for http-server@^0.11.1 fetched in 616ms
11
7 http fetch GET 304 https://registry.npmjs.org/p5-manager 596ms (from cache)
12
8 silly pacote registry packument for p5-manager@^0.4.2 fetched in 618ms
13
9 http fetch GET 304 https://registry.npmjs.org/hpm-cli 603ms (from cache)
14
10 silly pacote registry packument for hpm-cli@^2.0.1 fetched in 621ms
15
11 http fetch GET 304 https://registry.npmjs.org/create-react-app 613ms (from cache)
16
12 http fetch GET 304 https://registry.npmjs.org/local-npm 607ms (from cache)
17
13 silly pacote registry packument for create-react-app@^2.1.1 fetched in 628ms
18
14 silly pacote registry packument for local-npm@^2.2.2 fetched in 627ms
19
15 http fetch GET 304 https://registry.npmjs.org/node-gyp 610ms (from cache)
20
16 silly pacote registry packument for node-gyp@^3.8.0 fetched in 631ms
21
17 http fetch GET 304 https://registry.npmjs.org/bower 623ms (from cache)
22
18 silly pacote registry packument for bower@^1.8.4 fetched in 638ms
23
19 http fetch GET 304 https://registry.npmjs.org/yarn 612ms (from cache)
24
20 silly pacote registry packument for yarn@^1.12.3 fetched in 635ms
25
21 http fetch GET 304 https://registry.npmjs.org/gatsby-cli 622ms (from cache)
26
22 silly pacote registry packument for gatsby-cli@^2.4.15 fetched in 641ms
27
23 http fetch GET 304 https://registry.npmjs.org/nodemon 620ms (from cache)
28
24 silly pacote registry packument for nodemon@^1.18.7 fetched in 644ms
29
25 http fetch GET 304 https://registry.npmjs.org/eslint 633ms (from cache)
30
26 silly pacote registry packument for eslint@^5.9.0 fetched in 653ms
31
27 http fetch GET 304 https://registry.npmjs.org/snyk 633ms (from cache)
32
28 silly pacote registry packument for snyk@^1.112.0 fetched in 662ms
33
29 http fetch GET 304 https://registry.npmjs.org/npm 647ms (from cache)
34
30 silly pacote registry packument for npm@^6.9.0 fetched in 682ms
35
31 verbose stack TypeError: Cannot read property 'length' of undefined
36
31 verbose stack at dotindex (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:59:32)
37
31 verbose stack at /usr/local/lib/node_modules/npm/node_modules/text-table/index.js:11:21
38
31 verbose stack at Array.forEach (<anonymous>)
39
31 verbose stack at forEach (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:73:31)
40
31 verbose stack at /usr/local/lib/node_modules/npm/node_modules/text-table/index.js:10:9
41
31 verbose stack at Array.reduce (<anonymous>)
42
31 verbose stack at reduce (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:63:30)
43
31 verbose stack at module.exports (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:9:20)
44
31 verbose stack at /usr/local/lib/node_modules/npm/lib/outdated.js:130:16
45
31 verbose stack at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
46
31 verbose stack at outdated_ (/usr/local/lib/node_modules/npm/lib/outdated.js:221:12)
47
31 verbose stack at skip (/usr/local/lib/node_modules/npm/lib/outdated.js:343:5)
48
31 verbose stack at updateDeps (/usr/local/lib/node_modules/npm/lib/outdated.js:446:7)
49
31 verbose stack at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
50
31 verbose stack at Promise.successAdapter [as _fulfillmentHandler0] (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/nodeify.js:23:30)
51
31 verbose stack at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:566:21)
52
32 verbose cwd /Users/dangranger
53
33 verbose Darwin 18.2.0
54
34 verbose argv "/usr/local/Cellar/node/11.11.0/bin/node" "/usr/local/bin/npm" "outdated" "-g"
55
35 verbose node v11.11.0
56
36 verbose npm v6.9.0
57
37 error Cannot read property 'length' of undefined
58
38 verbose exit [ 1, true ]
59
Can anyone help resolve this issue for me?
Thanks
Advertisement
Answer
If you do not want to go through the bother of uninstalling and reinstalling Node, you can manually edit the “lib/outdated.js” file located in the “npm/node_modules/npm” path with the patch from the npm Github site at npm “outdated -g” patch
The fix is as simple as adding “|| ‘global'” to one line. Works fine and will stay in place until the next npm update.