2017-07-23 29 views
0

打印數據我在我的程序中使用console.table,test.js顯示數據但沒有運氣。無法使用console.table

require('console.table'); 

var values = [ 
     ['max', 20], 
     ['joe', 30] 
]; 
console.table(['name', 'age'], values); 

當我運行這個程序,我什麼也沒有在屏幕上

$ node test.js 
$ 

我已經安裝了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 
$ 

我使用Ubuntu 16.04,請諮詢。

+0

你能告訴我節點版本嗎? –

回答

1

這個問題的console.table不是。 其實console.table沒有版本節點上運行7+

版本節點6.11

輸出這個

enter image description here

和版本節點8.0

輸出

enter image description here

+0

Opps,我的筆記本電腦上的當前節點版本是8.2.1 –

+0

@JoelDivekar如果它是正確的,則將其標記爲正確。 –

1

是否安裝了console.table軟件包?

如果沒有再安裝首先安裝使用

npm install --save console.table 

試試這個

require('console.table') 
 
var values = [ 
 
     ['max', 20], 
 
     ['joe', 30] 
 
]; 
 
console.table(values);

這是我的輸出

Output

我想你的腳本,以及和我得到的結果

Output

+0

這對我來說工作正常 –