Viewing the dependency tree of a npm package without installing
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.
Viewing the dependency tree
We can view the dependency tree of any npm package before installing it, by using the npm-remote-ls
package.
Run the below command to install it globally:
npm install npm-remote-ls -g
In macOs, you need to add
sudo
before the above command.
Now, you can view the dependency tree of an npm package like this:
npm-remote-ls react
Output:
➜ ~ npm-remote-ls react
└─ react@16.13.1
├─ object-assign@4.1.1
├─ prop-types@15.7.2
│ ├─ loose-envify@1.4.0
│ │ └─ js-tokens@4.0.0
│ ├─ object-assign@4.1.1
│ └─ react-is@16.13.1
└─ loose-envify@1.4.0
You can view the dependency tree for the specific version of an npm package like this:
npm-remote-ls react@15
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.