Introduction
Hey guys, you might remember the post I posted a few days ago where we built an NPM package but sadly, didn't deploy it. Well in this post I will teach you how to publish an NPM package or in this case, the colours
package which we made in the last post. So let's get started. But wait, you need an NPM account.
Installation
Firstly you need to install the NPM cli. Generally, NPM comes with the Node installer but if you are on MacOS then simply run this command to install Node and NPM, brew install npm
. This will install NPM and Node.
Login to NPM
Now we need to authenticate our NPM account in the cli. Do that by this command, npm adduser
. This will prompt you to enter your username, password and email. After you successfully enter your credentials your account will be authenticated.
Update package.json
You need to make sure that you have filled all the fields in the default package.json
and also make sure you have a GitHub repository where you have stored your code.
Create a README.md
Before we publish our package, a README is a great way of expressing and describing your package. It allows you and your users to know more about the package, how to install it and configurations, so make sure to include these things in your README.md file.
Publishing the Package
Okay, you may think this is easy and it is! But you may or may not face errors while publishing so I have put down links below on common errors, if the links below help you out them tell me that in the comments.
So we can publish our very first and very own package through the npm publish
command. This command will output some gibberish at first but after that you will see whether or not you have an error or your package is published.
NOTE: At the end of the article I have put down some links to help you solve your errors.
Conclusion
We are done! That was all, and hopefully now you are already testing it in your systems which is awesome and if that was awesome then please don't forget to react with some awesome emojis to this post and as promised down are a few links for a few common errors.