Package management basics for web developer
As a developer, you will realize that most of the time we will write code and try to solve problems by writing code, from day to day a repetition will be created not only in the project you are working on but also when you will switch between different projects, sometimes it will be small implementations and sometimes big changes that will push you to copy and paste big blocks of code.
Many developers have been facing this dilemma since the beginning of time and many solutions have been proposed, so I’d like to discuss today about the package manager.
A package manager is a tool or application that allows developers to add and manage dependencies in their projects (or add them to your project and also the possibility to write your own packages.)
In reality you don’t need the packager manager, you can do it manually, download and reference the library in your code and use it, but it will become very tedious especially when the list starts to become big and you should take into account the different versions compatible with your code base.
For the package manger to work, it must know where it has to go to get the dependencies, this is where the Package Registry comes in. So we can define them as a warehouse where are stored the different packages according to their version, in this way the developer can decide which version of a package he wants to add in his project. It should also be noted that it is possible to have its own package registry often used for packages specific to a company.
npm install axios
The second package manager is yarn, which respect the same principle of operation as npm, it also has its specificity I invite you to read this article
Like npm(Node Package Manager) and Yarn(Yet Another Resource Negotiator), python also has its own package registry which is The Python Package Index (PyPI) which is the repository that contains all the applications that you can add to yours as depandances.
By installing python you get pip which is the standard package manager of python, next to that you find Pipenv and Postry which are also very successful in the community.
pip install faker
Or you can launch the installation from your requirements.txt file(this file content the list of depqndqnies to the projet with their version)
pip install -r requirements.txt
little tip to use to create a requirement file that will contain the list of all your depandancies
pip freeze >> requirements.txt
Go Modules is the easiest way to manage your depandaces in Go, to initialize it you just have to launch the command
go mod init
go get email@example.com
go get github.com/go-chi/chi@master
package management in projects is a bigger topic, I hope we will have time to share more in the future, this post was intended to briefly introduce you to the different package managers and their use.