LEARNNode CLI Automation

Node package.json Essentials

A well-maintained npm package has a couple of things that make it different from the rest. For instance, it has a detailed readme, a proper license, some keywords, and a detailed author description. Let’s discuss them one by one.

Readme File

The readme is extremely important since its content is what appears on your package page on npmjs. You need to write all the necessary documentation inside of it like the installation guide or usage guide, etc. So make sure you have everything inside of it that your user might need.

License

Your npm package should have a proper open-source license. You can add one by using a package called license. For instance, if you are interested in an MIT license, just go ahead and run the following command inside your terminal.

npx license MIT

Now open your package.json file and add a license field there with MIT as its value.

You can also use any other license that you want.

Keywords

This field is usually empty in your package.json when you do npm init. It is an array that takes the keyword related to your project. Users can look up your package using these keywords. For instance, if you are building a name CLI, you can add your name inside this field.

Author

Last but not least you have an author field inside your package.json file. This field takes a value. You can also give it an object and give your information inside it like this:

"author": {
"name": "Ahmad Awais",
"email": "[email protected]",
"url": "https://twitter.com/MrAhmadAwais"
},

Now go ahead and publish your package again on npmjs with all of the things that I discussed.

Wrapping Up

If your package is well maintained and has all the required fields, there is a great chance that the people will use it. Because they will see that the author has made sure that everything is up-to-date and up-to-mark.

Posted by Saad (It's a work in progress: Needs copy editing review by Awais.)