Chapter 13. Writing modules: Mastering what Node is all about
This chapter covers
- Planning a module
- Setting up a package.json file
- Working with dependencies and semantic versioning
- Adding executable scripts
- Testing out a module
- Publishing modules
The Node package manager (npm) is arguably the best package manager any platform has seen to date. npm at its core is a set of tools for installing, managing, and creating Node modules. The barrier to entry is low and uncluttered with ceremony. Things “just work” and work well. If you aren’t convinced yet, we hope this chapter will encourage you to take another look.
The subtitle for this chapter is “Mastering what Node is all about.” We chose this because user-contributed modules make up the vast majority of the Node ecosystem. The core team decided early on that Node would have a small standard library, containing just enough core functionality to build great modules upon. We knew understanding this core functionality was paramount to building modules, so we saved this chapter for the end. In Node, you may find 5 or 10 different implementations for a particular protocol or client, and we’re OK with that because it allows experimentation to drive innovation in the space.
One thing we’ve learned through our experimentation is that smaller modules matter. Larger modules tend to be hard to maintain and test. Node enables smaller modules to be stuck together simply to solve more and more complex problems.