The most popular way of making a package available to developers is publishing it to
npm, the package manager for Node.js.
We used it in all the examples in this book and you have seen how easy it is to install a package: It is just a matter of running
npm install package, and that is it. What you may not know is how easy it is to publish a package as well.
First of all, if you move into an empty directory and write in your terminal:
package.json is created and some questions will be displayed. The first one is the package name, which defaults to the folder name, and then the version number. These are the most important ones because the first is the name that the users of your package will refer to when they install and use it; the second helps you release new versions of your package safely and without breaking other people's code.
The version number is composed of three numbers separated by a dot and they all have a meaning. The last number of the package...