在我正在使用的node.js脚本中,我希望将所有node.js模块(使用npm安装)打印到命令行。我该怎么做呢?
console.log(__filename);
//now I want to print all installed modules to the command line. How can I do this?
发布于 2012-12-21 08:05:59
使用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.js
null { name: 'x11', version: '0.0.11' }
发布于 2014-10-11 16:06:44
如果您只对全局安装的软件包感兴趣,而没有完整的树,那么:
npm -g ls --depth=0
或本地(省略-g):
npm ls --depth=0
发布于 2014-09-12 22:34:16
所有全局安装的第三方模块列表,在控制台中写入:
npm -g ls
https://stackoverflow.com/questions/13981938
复制相似问题