node.js - 无法检查过时的全局 npm 包

标签 node.js npm

我正在学习 npm 教程,我们正在学习的一个命令是 npm outdated -g 来检查是否有任何全局包已过期。

每当我运行该命令时,都会收到错误:

npm ERR! Cannot read property 'length' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/samlegros/.npm/_logs/2019-03-28T00_46_47_834Z-debug.log

我正在运行 npm 6.9.0node 10.15.2

这是与之相关的错误日志:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'outdated', '-g' ]
2 info using <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d7b9a7ba97e1f9eef9e7" rel="noreferrer noopener nofollow">[email protected]</a>
3 info using <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ae4e5eeefcafcbbbaa4bbbfa4b8" rel="noreferrer noopener nofollow">[email protected]</a>
4 verbose npm-session bc4abe7eb4488494
5 http fetch GET 304 https://registry.npmjs.org/express-generator 273ms (from cache)
6 silly pacote registry packument for express-generator@^4.16.0 fetched in 284ms
7 http fetch GET 304 https://registry.npmjs.org/http-server 278ms (from cache)
8 http fetch GET 304 https://registry.npmjs.org/text-table 274ms (from cache)
9 silly pacote registry packument for http-server@^0.11.1 fetched in 291ms
10 silly pacote registry packument for text-table@^0.2.0 fetched in 290ms
11 http fetch GET 304 https://registry.npmjs.org/jshint 278ms (from cache)
12 silly pacote registry packument for jshint@^2.10.1 fetched in 292ms
13 http fetch GET 304 https://registry.npmjs.org/node-dev 280ms (from cache)
14 http fetch GET 304 https://registry.npmjs.org/grunt-cli 285ms (from cache)
15 silly pacote registry packument for node-dev@^3.1.3 fetched in 294ms
16 silly pacote registry packument for grunt-cli@^1.3.2 fetched in 295ms
17 http fetch GET 304 https://registry.npmjs.org/create-react-app 289ms (from cache)
18 http fetch GET 304 https://registry.npmjs.org/sequelize-cli 283ms (from cache)
19 silly pacote registry packument for create-react-app@^2.1.8 fetched in 301ms
20-31...
32 silly pacote registry packument for ionic@^3.20.0 fetched in 344ms
33 http fetch GET 304 https://registry.npmjs.org/cordova 350ms (from cache)
34 silly pacote registry packument for cordova@^8.0.0 fetched in 370ms
35 http fetch GET 304 https://registry.npmjs.org/npm 364ms (from cache)
36 silly pacote registry packument for npm@^6.9.0 fetched in 391ms
37 verbose stack TypeError: Cannot read property 'length' of undefined
37 verbose stack     at dotindex (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:59:32)
37 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/text-table/index.js:11:21
37 verbose stack     at Array.forEach (<anonymous>)
37 verbose stack     at forEach (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:73:31)
37 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/text-table/index.js:10:9
37 verbose stack     at Array.reduce (<anonymous>)
37 verbose stack     at reduce (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:63:30)
37 verbose stack     at module.exports (/usr/local/lib/node_modules/npm/node_modules/text-table/index.js:9:20)
37 verbose stack     at /usr/local/lib/node_modules/npm/lib/outdated.js:130:16
37 verbose stack     at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
37 verbose stack     at outdated_ (/usr/local/lib/node_modules/npm/lib/outdated.js:221:12)
37 verbose stack     at skip (/usr/local/lib/node_modules/npm/lib/outdated.js:343:5)
37 verbose stack     at updateDeps (/usr/local/lib/node_modules/npm/lib/outdated.js:446:7)
37 verbose stack     at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
37 verbose stack     at Promise.successAdapter [as _fulfillmentHandler0] (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/nodeify.js:23:30)
37 verbose stack     at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:566:21)
38 verbose cwd /Users/samlegros/Documents/Development/Tutorials/lynda-become-a-mern-stack-javascript-developer/learning-npm-the-node-package-manager/exercise-files/CH2/02_01/start
39 verbose Darwin 18.2.0
40 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "outdated" "-g"
41 verbose node v10.15.2
42 verbose npm  v6.9.0
43 error Cannot read property 'length' of undefined
44 verbose exit [ 1, true ]

任何帮助将不胜感激。谢谢。

最佳答案

根据 github 上的 npm-cli,npm 存在过时的问题。它已于几周前修复,因此您可能必须等到 npm 的下一次更新发布才能发布修复程序。

链接:npm outdated fix

关于node.js - 无法检查过时的全局 npm 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55388605/

相关文章:

javascript - Jest SpyOn 值而不是 getter

node.js - 无法通过npm install安装 'weak'模块

npm - VS2015 的开发人员命令提示符中未将“npm”识别为内部或外部命令错误

node.js - 如何在 Node js中将彩色图像(jpg,jpeg,png)更改为黑白或灰度

javascript - 从连接的套接字查找命名空间或 URL 信息?

arrays - Joi 验证正则表达式或模式

vue.js - 使用 connect-history-api-fallback' ,但不知道如何在 vuejs 中实现

javascript - 登录失败的客户端通知

javascript - 为什么 import 关键字在 React 中起作用,而在普通的 npm init 项目中不起作用?

node.js - 我在安装 Cordova 时遇到错误