DEV Community

Minh Hang Nguyen
Minh Hang Nguyen

Posted on

Publishing my first package

This week, I've published my 1st package on npm - mh-ssg - a static site generator CLI.

The process is not complicated and only involves 4 steps:

1. Configure the package

In the package.json, I need to make sure that I have all the required information filled: name and version. When the package is first published, usually it should be version 1.0.0.

2. Publish the package

In order to publish package on npm, I had to first create an account on the website. Then log in from the command line with:

npm login
Enter fullscreen mode Exit fullscreen mode

After successfully logging in, I can publish the package with:

npm publish --access public
Enter fullscreen mode Exit fullscreen mode

3. Test the package

I asked my friend for help to test the package I just published. She was able to install the package but when she tried to run it, she found a bug and noticed that was outdated. Following her feedbacks, I fixed the bug and updated with more instructions on how to use the tool.

4. Update the package

When all the bug fixes were in place, I updated the version in package.json with any related test cases, committed those changes and did a final npm publish.

Now mh-ssg is available on npm and ready to be used by the community. The tool can be installed with the simple command:

npm i mh-ssg
Enter fullscreen mode Exit fullscreen mode

Top comments (0)