使用npm ls(甚至还有json输出)
从脚本中:
test.js:
function npmls(cb) { require('child_process').exec('npm ls --json', function(err, stdout, stderr) { if (err) return cb(err) cb(null, JSON.parse(stdout)); });}npmls(console.log);跑:
> node test.jsnull { name: 'x11', version: '0.0.11' }


