Starting out in my JavaScript journey there were a few things I was told to just "accept" and not worry about how they work. There are plenty of processes and moving parts when writing code and one that I never quite understood was NPM. NPM stands for Node Package Manager, and is used in a few ways. NPM provides an online database of 'packages' or JavaScript tools that can be published by anyone and used in your projects. On top of being an online database, NPM is also a command line tool used to interact with that database and install/manage the packages you install from the database!
What is a package, though?
Think of packages like the brick and mortar of your applications. You can install and combine multiple packages together in order to create the most efficient program for your end users and all those packages are easily maintained by NPM. The NPM database helps keep all your packages up to date by allowing the packages to be managed and updated by their publishers and other developers. Whenever an update or improvement is made to a package and uploaded to NPM's database, all users who currently use that package can easily fetch those updates from the server and always keep their packages up to date. NPM also helps handle package dependencies.
What is a dependency?
Some packages are built directly upon other packages in NPM and 'depend' on them to function properly; these relationships are called dependencies. Dependencies would typically cause problems when trying to use different packages, but NPM handles all the hard work for you. When installing packages through NPM the service will automatically search for and install all required dependencies for any packages you're attempting to use/install.
In conclusion:
NPM is a wonderful tool for developers to not only share reusable code, but to keep that code updated and working for all future projects. There are hundreds of packages to chooses from and plenty that can be built and expanded upon. Who knows, maybe one day you'll be posting and updating a package of your own for the world to use!
A few of the most popular libraries (in no particular order, just ones I'd heard of or used before) are:
jQuery: a small and fast feature-rich JavaScript library making HTML document traversal, manipulation, and event handling much easier.
Express: noted as one of the best NPM packages offering a server framework for web applications.
Lodash: A particularly useful tool, especially when working with lots of numbers or arrays. Makes the creation of complex functions much easier.
React: a declarative, efficient, and flexible JavaScript library for building user interfaces.
Top comments (1)
Thats a good explanation.