In this tutorial, we are going to learn about how to view the dependency tree of a npm package or module before installing it locally or globally in our system.
We can view the dependency tree of any npm package before installing it, by using the
Run the below command to install it globally:
npm install npm-remote-ls -g
In macOs, you need to add
sudobefore the above command.
Now, you can view the dependency tree of an npm package like this:
➜ ~ npm-remote-ls react └─ email@example.com ├─ firstname.lastname@example.org ├─ email@example.com │ ├─ firstname.lastname@example.org │ │ └─ email@example.com │ ├─ firstname.lastname@example.org │ └─ email@example.com └─ firstname.lastname@example.org
You can view the dependency tree for the specific version of an npm package like this:
Similarly, if you are using the npm version
5.2 or greater you view it using
npx, no need of installing the
npm-remote-ls package globally.
npx npm-remote-ls express
You can also check out, How the view the dependency tree of installed npm packages.