NodeJS: List Installed Package on Global/Local Dependencies

Viewing 1 post (of 1 total)
  • Author
  • #9499

    Sometimes when we are getting started with NodeJS, we forgot to learn the basics. Along the way of the learning process, we ask, wait a minuted what did I installed locally on my project and on global dependencies. We started searching and you’re now in the right place. So, let’s start!

    First, we need to know what is global dependencies and what is local. Global dependency is a global package within the operating system where NodeJS is installed. Having this explanation, we conclude that any package that is installed globally can be accessed on any of our project on the same machine. Next is dev dependency or I call local. Local is packages that are installed only on our project meaning, it is store on root/node_modules/. Just to give you an example, NPM is also a package in NodeJS yet globally installed so that we can install package to any of our projects.

    Now, how can we get the list of global and local packages installed?

    To view you global dependency, just execute the command:
    npm list -g --depth 0

    To view your local dependency, just execute the command.
    npm list --depth 0

    What does –depth 0 do? It is a parameter passed that we only need a depth of only one, meaning the parent modules only. Hope you liked this topic and come back for more! To know more about NodeJS tips and tricks to maximize your productivity. Subscribe to this forum: NodeJS: From Zero to Hero.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic. Login here