There are many great resources about how to publish your own
npm packages, but I want to share a few thoughts on why you should be publishing your own
npm packages and why it will make you a better developer.
If you are looking for a technical overview of building
npm packages, Dan Vega wrote a particularly thorough post about publishing your first
npm package. I would highly recommend that any beginners read Dan’s guide.
For example, the popular request package enables developers to make
http calls by simplifying the functions needed to handle all the complexities of
http calls into easy-to-use methods.
In the process of building our own npm packages and Visual Studio Code extensions, we have learned quite a bit about how to integrate npm packages into the development process and why publishing our own packages has made us better developers. Below are a few of the lessons we have learned.
Developers are builders, constantly starting new projects, trying new technologies, and contributing to community initiatives. For many developers, building a portfolio is an important way to showcase the skills and abilities they have honed over time.
During their careers, developers are likely to work on projects that are intertwined with other projects. npm packages, however, can be standalone snippets of your work that you will be able to quickly and easily share with colleagues, employers, and friends.
Not only will you be able to demonstrate your programming skills, you will also have the opportunity to showcase your ability to write documentation that is easy to read and understand. npm packages are publicly available to the developer community, so you will be responsible for packaging your module for use by other developers.
Communication is an invaluable skill for developers of all backgrounds.
Many of my personal side projects are horrifying examples of spaghetti code. When writing code for myself, it is tempting to cut corners and fall into bad habits. Even my own code is illegible to me if I revisit a project after not looking at it for a while.
To build something that any developer in the world can use is a rare, yet powerful, opportunity. And with great power comes great responsibility.
As other developers find your project, you will need to learn how to write clear and concise documentation. You will also need to organize your project on GitHub, or another repository hosting service, so that any potential contributors or curious developers will be able to peruse your code. You will wrestle with how to best name your functions so that others can understand how they work.
By building an npm, you will walk a mile in the shoes of another developer. You will begin to understand how someone else will view your project. In the process, you will become a smarter developer who is better attuned to the needs of the community around you.
Individual developers who are looking to take ownership of a project will learn a lot from designing their own npm package. Building an npm package requires you to oversee the entire product development cycle, from ideation to public release and beyond.
At each point in the cycle, you will be exposed to new challenges and unique learning opportunities. You will juggle everything from architecture planning to pull request reviews. You become a manager for your own mini-product.
npm packages offer the perfect combination of scale and power. Building an npm is not so complex and overwhelming that you will be unable to finish, yet the final product will have the potential to help a whole community of developers.
Open source software is the lifeblood of the software development world. Even so, contributing to open source projects can often be intimidating, especially for beginners.
Finding a project you would like to contribute to, perusing contribution guidelines, submitting pull requests for maintainers to review—the entire process can feel a bit overwhelming at times.
If you are looking for an easier way to give back to the open source community, publishing an npm package is a great opportunity for beginners and experienced developers alike. npm packages can be as simple or as complex as you want them to be. No project is too small to have an impact.
Once your npm package is publicly available, other developers are likely to have feedback or suggestions. Ideally, some developers will even submit pull requests to your project on GitHub.
Interacting with the development community and learning how to incorporate feedback will help you hone your leadership and project management skills.
Suggestions from other developers will also help you become a better developer by exposing you to new and better development practices or tools that you can then carry over to any other projects you may be working on. Pull request reviews and issue discussions are wonderful opportunities to learn from the community.
Application architecture can get messy, fast. Writing tests for complicated code is, unsurprisingly, also complicated. Code often involves many moving pieces that can get tangled in unforeseen ways by unsuspecting developers.
Abstracting parts of your code and organizing them into modular npm packages will declutter your codebase and help you better leverage reusable code across different parts of your application. Code can be quickly shared between team members, and redundant instances of functions can be eliminated. The result is a cleaner and more manageable codebase.
Modular code also enables modular testing. By separating your code into packages, you can write and execute reproducible tests to ensure that each package is functioning as expected. Most npm packages are built so that anyone can install and run tests that are included with the package. As a developer, you will write better tests by maintaining close proximity between your tests and the original code, as npm packages require you to do.
With npm packages to abstract your application’s reusable functionality, you will add structure and organization to your code that will streamline your development process.
Creating and publishing your own npm can be a rewarding experience for any developer of any skill level. By learning how to build your own open source product and managing its release to the developer community, you will supercharge your developer skill set.
For development teams, modularizing your code into individual packages can accelerate development by standardizing some of the processes needed to manage your code. npm packages streamline the entire build, test, and deploy workflow—a big benefit for your team to use and reuse throughout your codebase and for the open source community at large.