Ok then packages is not exactly a JavaScript concept, it's just the name that we give to the unit of distribution through npm/yarn.
Libraries or software that gets "packaged", distributed, indexed in a common website (the npm repository) and then can be installed from a client. npm or yarn are the package managers, the piece of software that you add as a dependency in your application is called a package.
JavaScript modules are instead a recent addition to the standard. They allow you to organize code in files and import them from one another, encapsulated in a namespace (instead of having everything global like in the old days). So you might have a module that contains common behavior and import it from multiple files. Es:
I think this is the simplest explanation I can make, if you want to know more, this is a complete overview on how JavaScript modules work: developers.google.com/web/fundamen...
Top comments (5)
In the context of which language? They usually mean slightly different things depending on the context
CONTEXT IN JS
in my opinion, package is all thing in npmjs.com, what you can install for your project
if the package have been installed in your project, i call that module. Because i can import all code from (package installed) to my project.
so package == not yet installed
and module === have been installed, and ready for import to your project
In the context of javascript
Ok then packages is not exactly a JavaScript concept, it's just the name that we give to the unit of distribution through npm/yarn.
Libraries or software that gets "packaged", distributed, indexed in a common website (the npm repository) and then can be installed from a client. npm or yarn are the package managers, the piece of software that you add as a dependency in your application is called a package.
JavaScript modules are instead a recent addition to the standard. They allow you to organize code in files and import them from one another, encapsulated in a namespace (instead of having everything global like in the old days). So you might have a module that contains common behavior and import it from multiple files. Es:
and then in your app you can import:
I think this is the simplest explanation I can make, if you want to know more, this is a complete overview on how JavaScript modules work: developers.google.com/web/fundamen...
Very nice. Thank you