![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
List contents of directories in tree-like format.
Tree-cli is a recursive directory listing program that produces a depth indented listing of files. With no arguments, tree lists the files in the current directory. When directory arguments are given, tree lists all the files and/or directories found in the given directories each in turn. Upon completion of listing all files/directories found, tree returns the total number of files and/or directories listed.
cmd:
tree -l 2 -o output.txt
result:
/Applications/XAMPP/htdocs/node_playground/tree-cli
├── README.md
├── bin
| └── tree
├── node_modules
| ├── bluebird
| ├── chalk
| ├── cli-spinner
| ├── meow
| └── object-assign
├── package.json
└── tree.js
directory: 7 file: 4
npm install -g tree-cli
tree
or treee
(to avoid confliction with system command).NOTE: use treee
instead of tree
on windows system.
tree/treee
require('tree-cli')({
base: '.', // or any path you want to inspect.
noreport: true
}).then(res => {
// res.data is the data for the file tree.
// res.report is the stringified scanning report.
console.log(res.data, res.report);
});
You can find the type declaration for the exporting function and the type declaration of its' params and result in the 'types/index.d.ts' file. If you are using VSCode, you'll find the type hint during your typing.
Breaking change: In version before 0.6.0, the resovled result is the tree structure of the scanned directory. But in latest v0.6.0, the resolved result is changed to a object contains both the file tree structure and the scanned report. The structure of result would be:
{
data: {
// ...The file node tree.
},
report: '...', // The final report.
}
tree --help
use -l levelNumber
to specify the path level.
tree -l 2
use -o outputFilePath
to specify the output file.
tree -l 2 -o out.txt
use -d
to show directories only.
tree -l 2 -o out.txt -d
see Options.
you should just use the treee
command as tree
has been already taken by windows system.
treee -l 2 -o out.txt -d
'node_modules/, .git/, .gitignore'
FAQs
List contents of directories in tree-like format.
The npm package tree-cli receives a total of 0 weekly downloads. As such, tree-cli popularity was classified as not popular.
We found that tree-cli demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.