Print a list of all installed node.js modules

后端 未结 7 2053
情话喂你
情话喂你 2020-12-22 17:29

In a node.js script that I\'m working on, I want to print all node.js modules (installed using npm) to the command line. How can I do this?

console.log(__fil         


        
7条回答
  •  星月不相逢
    2020-12-22 17:48

    Why not grab them from dependencies in package.json?

    Of course, this will only give you the ones you actually saved, but you should be doing that anyway.

    console.log(Object.keys(require('./package.json').dependencies));
    

提交回复
热议问题