admin管理员组文章数量:1419232
I am using console.table in my program, test.js to display data but with no luck.
require('console.table');
var values = [
['max', 20],
['joe', 30]
];
console.table(['name', 'age'], values);
And when I run this app I get nothing on the screen
$ node test.js
$
I have already installed console.table
$ npm install --save console.table
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
+ [email protected]
updated 1 package in 0.687s
$ node test.js
$
I am using Ubuntu 16.04, kindly advice.
I am using console.table in my program, test.js to display data but with no luck.
require('console.table');
var values = [
['max', 20],
['joe', 30]
];
console.table(['name', 'age'], values);
And when I run this app I get nothing on the screen
$ node test.js
$
I have already installed console.table
$ npm install --save console.table
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
+ [email protected]
updated 1 package in 0.687s
$ node test.js
$
I am using Ubuntu 16.04, kindly advice.
Share Improve this question edited Jul 23, 2017 at 8:47 Joel Divekar asked Jul 23, 2017 at 7:17 Joel DivekarJoel Divekar 1871 gold badge6 silver badges22 bronze badges 1- Can you tell me the node version? – Himanshu sharma Commented Jul 23, 2017 at 10:47
3 Answers
Reset to default 5Have you install console.table package or not.
If you didn't install then first install using
npm install --save console.table
Try this
require('console.table')
var values = [
['max', 20],
['joe', 30]
];
console.table(values);
This is my output
I am trying your script as well and I am getting result
Well for upper version of node.js you need not to install console.table
if still you install you have to use console.table like as follows.
delete console.table;
require('console.table');
or
require('console.table')({force: true})
This issue is not of console.table . Actually console.table does not work on version node 7+
version node 6.11
the output is this
and in version node 8.0
the output is
I have used a frame work called columnify - npm install columnify
const columnify = require('columnify');
//Connect to datbase (mypany) collection
db.collection('employee').find({}, {projection:{_id: 0}}).toArray((err, allRecords) => {
//Error checking
if (err) {
console.log('Error encontered!!!');
} else {
console.log(columnify(allRecords));
process.exit(0);
};
});
本文标签: javascriptUnable to print data using consoletableStack Overflow
版权声明:本文标题:javascript - Unable to print data using console.table - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745301377a2652391.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论