npm list will generate a dependency tree for the project in the current directory and print it to the console.
npm list
Out will be similar to the following image. It will give only the top-level dependency list.
![](https://i0.wp.com/arjunphp.com/wp-content/uploads/2022/12/image-3.png?resize=231%2C177&ssl=1)
To get the full tree of npm dependencies
npm list -a
or
npm list --prod --all
--prod
flag is to list only production dependencies
Out will be similar to the following image. It will give the full tree of dependencies.
![](https://i0.wp.com/arjunphp.com/wp-content/uploads/2022/12/image-4.png?resize=496%2C540&ssl=1)
You can get the dependency tree of a specific dependency
npm view [dependency] dependencies
Out will be similar to the following image.
![](https://i0.wp.com/arjunphp.com/wp-content/uploads/2022/12/image-6.png?resize=575%2C626&ssl=1)
You can also set the maximum depth level by doing
npm list --depth=[depth]
You will get a similar output with npm list --depth=1
command. It will give the full tree of dependencies.
![](https://i0.wp.com/arjunphp.com/wp-content/uploads/2022/12/image-5.png?resize=570%2C559&ssl=1)