For this course, we are going to be using NPM Workspaces to configure our monorepo. We will have two workspaces, one for our apps and one for our libraries. We configure those in our package.json.
Alejandro Ñáñez: [0:00] Let's start by creating our package.json file by running npm init -y. [0:05] Now let's have the workspaces key, which is the one that will tell NPM to behave like a monorepo. Here, in this workspaces array, we are going to add all the folders that we want to be added to our monorepo. For this course, we are going to use apps and everything that is inside of it, and we are also going to use libs. Let's clean up things a little bit because we do not need test for now.
[0:32] Now, let's update the name property to monorepo. This could be anything, but the convention that we would like to use is the @ symbol and then the name of your company or your own name and all this is because in the future, when we have many packages in our monorepo, we will start calling them @monorepo/mypackage1, 2 and so forth.
[0:59] To recap, in order to have a monorepo managed by NPM Workspaces, we will need to add the workspaces property with an array of strings. Each one of the strings in the array represent the folder that will contain applications, libraries and whatever we want. This could also be just one folder, but for organization purposes, I prefer to use apps and libs.
[1:22] It is not mandatory, but it's a good practice to update the name of your package.json file with something that it starts with @, and then followed by your company name or your own name. We will have a standard way to name your packages in applications inside the monorepo.