https://github.com/imsnif/nmtree
Get a (flat) tree representation of the modules in your node_modules folder
https://github.com/imsnif/nmtree
javascript nodejs npm-package npm-scripts
Last synced: over 1 year ago
JSON representation
Get a (flat) tree representation of the modules in your node_modules folder
- Host: GitHub
- URL: https://github.com/imsnif/nmtree
- Owner: imsnif
- License: mit
- Created: 2017-11-17T18:02:20.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T09:31:21.000Z (over 3 years ago)
- Last Synced: 2024-05-02T02:25:44.047Z (about 2 years ago)
- Topics: javascript, nodejs, npm-package, npm-scripts
- Language: JavaScript
- Size: 4.97 MB
- Stars: 14
- Watchers: 3
- Forks: 5
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# nmtree
[](https://travis-ci.org/imsnif/nmtree) [](https://coveralls.io/github/imsnif/nmtree?branch=master) [](https://standardjs.com)
Get a node_modules directory with all its `package.json` files as a parsable flat tree.

### what is this?
Given an npm library, this tool would recursively go through its `node_modules` and create a flat tree with the paths of libraries as keys and their parsed `package.json` files as values.
eg.
```javascript
{
"myLib": ,
"myLib/node_modules/myDep": ,
"myLib/node_modules/myDep/node_modules/myOtherDep":
}
```
### install
`npm install -g nmtree` - for the cli tool
`npm install nmtree` for the `require`-able library
### usage
```javascript
const nmtree = require('nmtree')
const libPath = '/path/to/my/lib'
const tree = nmtree(libPath)
const installedReactVersions = Object.keys(tree).reduce((versions, libPath) => {
const { name, version } = tree[libPath]
if (name === 'react') versions.push(version)
return versions
}, [])
// or whatever else you can think of!
```
### command line usage
```
nmtree /path/to/my/lib > my-lib-node-modules.json
```
### License
MIT