Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

解决 Node.js 中通过 console.log 打印数组时长度的限制 #304

Open
wayou opened this issue Aug 20, 2021 · 0 comments
Open

解决 Node.js 中通过 console.log 打印数组时长度的限制 #304

wayou opened this issue Aug 20, 2021 · 0 comments

Comments

@wayou
Copy link
Owner

wayou commented Aug 20, 2021

解决 Node.js 中通过 console.log 打印数组时长度的限制

Node.js 中通过 console.log 打印组数到命令时,会有数量限制,超出部分会隐藏而展示成如下形式:

[ 'item',
  'item',
  'item',
  <...cut...>
  'item',
  'item',
  'item',
  ... 400 more items ]

解决办法还蛮多的,参考这个 StackOverflow 上的回答,这里给出最便捷的:

const util = require('util')
console.log(util.inspect(array, { maxArrayLength: null }))

我为什么会发现这么个问题呢,因为老早之前写了个 Webpack 插件打印些调试信息,有人提 issues 报了这个问题。

相关资源

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant