DEV Community


Module, Packages, Dependencies! What are they?

balaajimuthukumar profile image Balaji Muthukumar ・2 min read

Alt Text

Module is single file of code. Package is a group of modules in a directory. Dependencies are added files in a package to assist the module files to download other modules to have additional features without having to rewrite the code from scratch and use someone else's code.

This will be useful when you work in an organization and you are responsible for a module in a big project. The big projects are maintained by hundreds and thousands of developers(eg Linux os or Microsoft office..etc) where the project will have new features or bug fixes in weekly or monthly basis. These cannot be re-written from scratch. Let's say the big projects have lots of modules with duplicate copies across your system, How do you face this? Understand the entire project?. No, This is where having packages could save you. The packages are files arranged in a central repository in cloud or installed globally in your local pc so that you could import it in you module and use it. Now importing the external modules to your module, How do you do that? Simply by adding an "Import module_name"? Maybe. But in Javascript it does not work like that. The dependency files are created and the names of the files to be added are added in it. This will be read by the IDE to search and download the packages.

Unlike other programming languages, Javascript will need you to add packages individually for each project. This will be useful when you need to fix a bug in the package or do minor alterations in the packages will not affect the files globally and wont affect other people's work.

There are few things I thought should share for the noobs.

+Please don't try to add separate Javascript file for html if you are not using any framework. It wont work. There are factors like changing the script type to module or developing a Javascript listener and rendering the html file as well importing different modules need to done.

+Don't worry about the lines of code being too much or efficient. first try to produce output. Stressing too much will make you procrastinate.


Editor guide