Get a full module tree from package-lock.json
, yarn.lock
or node_modules/**
.
const getTree = require('universal-module-tree')
const tree = await getTree(__dirname)
console.log(JSON.stringify(tree, null, 2))
$ node example.js | head -n25
{
"children": [
{
"data": {
"name": "@yarnpkg/lockfile",
"version": "1.1.0"
},
"children": []
},
{
"data": {
"name": "read-package-tree",
"version": "5.2.1"
},
"children": [
{
"data": {
"name": "debuglog",
"version": "1.0.1"
},
"children": []
},
{
"data": {
"name": "dezalgo",
Or with NSolid:
const getTree = require('universal-module-tree')
nsolid.packages((err, packages) => {
if (err) throw err
const tree = getTree.fromNSolid(packages)
console.log(JSON.stringify(tree, null, 2))
})
$ npm install universal-module-tree
noDev
: excludedevDependencies
Copyright © NodeSource.
Licensed under the MIT open source license, see the LICENSE file for details.