Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,160,487 members, 7,843,479 topics. Date: Wednesday, 29 May 2024 at 06:27 AM

Help: I Need An In-depth Explanation On How Package Managers Work(npm And Yarn). - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Help: I Need An In-depth Explanation On How Package Managers Work(npm And Yarn). (300 Views)

Npm Run Build Problem (react) / Please Help I'm Getting Errors Why Installing Npm On Termux / Issue Which Nodejs And Npm After Installation (2) (3) (4)

(1) (Reply)

Help: I Need An In-depth Explanation On How Package Managers Work(npm And Yarn). by Winnerrrr(m): 9:11am On Dec 18, 2020
Hi Guys.

I've watched some videos on NPM and Yarn, I understood how they work, command lines and their basic functionalities.

But what I find confusing is, I couldn't understand their importance, Why are they used?, since one can just create a HTML/css/Js files, debug and all.

I need a breakdown on their relevance in development.

Thanks.

cc karleb pcguru1 and all of the dev guys here.
Re: Help: I Need An In-depth Explanation On How Package Managers Work(npm And Yarn). by 404Dev: 9:44am On Dec 18, 2020
They are for dependency management.

What is a dependency - code that your app depends on or relies upon to run.

WHy dependencies - well because most times we will need to use someone else's code, package, or library.

For instance, let's say you are building an app, and you wanted to create a modal and you don't want to code it yourself or don't know-how.

Then you can go on npm registry and see a package someone else created for adding modals to your app.

Now you have two options -

1. Either download the source files and add them to your projects
2. Or you can use npm or yarn to install it

The problem with going with option 1 is simply this - when the author updates the package or fixes a bug, then you have to go back and download the new files and replace the ones you have. If you have 5 or 10 of these packages - then painting your app would be a nightmare.

But you with npm or yarn you can just update your dependencies with one command.

Now, most packages have cdn links to their assets if you don't want to use yarn or npm but these are very limited.

Eg. if you use bootstrap cdn, you can't customize the theme options but if you install with either yarn or npm, you can customize the theme, compile it and run it within your project.

Hope this helps.

4 Likes

Re: Help: I Need An In-depth Explanation On How Package Managers Work(npm And Yarn). by Winnerrrr(m): 12:22pm On Dec 18, 2020
404Dev:
They are for dependency management.

What is a dependency - code that your app depends on or relies upon to run.

WHy dependencies - well because most times we will need to use someone else's code, package, or library.

For instance, let's say you are building an app, and you wanted to create a modal and you don't want to code it yourself or don't know-how.

Then you can go on npm registry and see a package someone else created for adding modals to your app.

Now you have two options -

1. Either download the source files and add them to your projects
2. Or you can use npm or yarn to install it

The problem with going with option 1 is simply this - when the author updates the package or fixes a bug, then you have to go back and download the new files and replace the ones you have. If you have 5 or 10 of these packages - then painting your app would be a nightmare.

But you with npm or yarn you can just update your dependencies with one command.

Now, most packages have cdn links to their assets if you don't want to use yarn or npm but these are very limited.

Eg. if you use bootstrap cdn, you can't customize the theme options but if you install with either yarn or npm, you can customize the theme, compile it and run it within your project.

Hope this helps.

Wow, Thanks for the detailed explanation.

I really understand it better now, I remembered in the tutorial I watched, the guy installed 'loadash' and went on the index.js file to loop through an array using .each() which is a method of 'loadash'.

Many Thanks.

(1) (Reply)

How Much Does It Cost To Develop An App For Truckers (features, Process, & Cost) / Intelligent Young And Dynamic Programmers Required For A Startup Incubation / Urgent Modification On A Php And Mysql App

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.