NPM error "npm Cannot read property 'length' of undefined"

问题

  • 出现错误版本npm 6.9.0
1
2
npm -g outdated
# 检测所有全局依赖包更新情况
  • 报错显示

image

修复方法

1
2
3
4
5
6
7
8
// 148行
var columns = [
depname,
has || "MISSING",
want,
latest,
deppath || "global" // 此处修改为这样
]

参考资料

  • “npm-outdated-throw-an-error-cannot-read-property-length-of-undefined”
  • “npm Cannot read property ‘length’ of undefined”