Introduction
This week we are asked to release our work by choosing a release method. To make our work, I decided to release my very first package on NPM. You can also check it out at here.
Why NPM?
There are several reasons why I decided to choose NPM as my release method. Firstly, NPM is super popular to the developers all around the world. Therefore, publishing my package on the site would be a good idea. Moreover, since all of the dependencies used in my projects are published on NPM, it gives me a solid reason to go with NPM
How?
To publish my first ever package on NPM, these are the steps that I took at the time:
After creating your first account, navigate to the root folder of your project. At the terminal, use this command to login:
npm login
- Next, create a
package.json
file in your folder.
npm init
You can change the name and the version of your package inside your package.json
file. Below is what I did in my file:
{
"name": "link-checker-tool",
"version": "1.0.2",
"description": "A tool used to check whether an URL is available or not",
"bin": {
"lct": "/link-checker.js"
},
"keywords": [
"cli"
],
"scripts": {
...
},
"preferGlobal": true,
"author": "Thanh Tien Phat Nguyen",
"license": "ISC",
"dependencies": {
...
},
"devDependencies": {
...
}
}
- To make it easy for other people understand how to use your package, update your README.md document which allows users to have some basic knowledge about your package. Below is a piece of my README.md, you can check the full version at here.
- Lastly, publish your package by using this command:
npm publish
If you get the message below, your package is published successfully.
How to use my package?
My package this is an CLI that checks if a url is available. Some of the features that I have added to this package is:
- Check and print all the good, bad and unknown links in a file.
- Read multiple files at once.
- Check the availability of an URL.
- Give the URL to an archived version of a website.
- Output JSON format of a URL entered.
To install my package, please use the command
npm install link-checker-tool
npm install -g link-checker-tool
For more usages of my package, you can read my whole document for more information.
What I learn from this week lab
- How to release a package
- How to improve the workflow by tagging my release.
Top comments (0)