Node.js 計算目錄內檔案數量

可以用 fs 或者 shelljs 來做,各有千秋

//using fs
fs = require('fs');
console.log((fs.readdirSync('../json/')).length);

//using shelljs
shell = require('shelljs');
console.log((shell.ls('../json/')).length);