DEV Community

Soham Thaker
Soham Thaker

Posted on

Publishing package to npm registry, tagging and doing a release, and beyond...

Release

You can find my release here.

Release tool and package registry used

npm

Installing the package

Installation instructions for node-tilify package can be found here.

Process of creating a release

I watched a couple of videos, read the documentation and a blog before I was able to successfully release the tool on npm. Videos watched include Creating Node.js modules & Publishing npm packages from npm's youtube channel and How To Create And Publish Your First NPM Package from Web Dev Simplified's youtube channel. Reading documentation included npm's very own documentation and blog includes Publishing a Node.js CLI tool to npm in less than 15 minutes. The steps I performed are below:

  1. Ran npm run adduser to create a user account on npm and link that user account locally to my machine. Ran npm version patch to upgrade the semver, followed by npm publish —access public to publish the package. Package was released with v1.0.0. Tested by running npm i node-tilify followed by node-tilify -h and it didn't work.

  2. I assumed the location of the index.js was incorrect so I moved it from /src dir to / root dir part of commit b832ef9e. Ran npm version patch to upgrade the semver, followed by npm publish —access public to publish the package. Package was released with patch release v1.0.1. Tested by running npm i node-tilify followed by node-tilify -h and it didn't work.

  3. I assumed the code within /index.js was exposed out in the open without being invoked by a function so I edited the code by putting all of the code into a function and then invoking that function at the bottom of /index.js part of commit 6597c56a. Ran npm version patch to upgrade the semver, followed by npm publish —access public to publish the package. Package was released with patch release v1.0.2. Tested by running npm i node-tilify followed by node-tilify -h and it didn't work.

  4. According to the blog that I read, it suggested adding a shebang line #!/usr/bin/env node at the top of index.js file so that systems like Unix can understand what executable to use to run the script, which in this case is node. Also added a property "bin": "./index.js" within /package.json file so that npm can install the package globally, refer to the bin entry and link the package name with the index.js file as specified in the ./package.json configuration parth of commit 1583e704. Ran npm version patch to upgrade the semver, followed by npm publish —access public to publish the package. Package was released with patch release v1.0.3. Tested by running npm i node-tilify followed by node-tilify -h and it didn't work.

  5. I missed one step from the blog, running npm link. npm link is a command-line tool for symlinking a local package as a dependency during development. It is commonly used for testing packages before publishing them. Ran npm link to link the package locally, followed by npm version patch to upgrade the semver, followed by npm publish —access public to publish the package. Package was released with patch release v1.0.4. Tested by running npm i node-tilify followed by node-tilify -h and it finally started working.

  6. It was then time to update the documentation with latest information on how to install the package from npm. I pushed the commit e8eb1820. Ran npm version patch to upgrade the semver, followed by npm publish —access public to publish the package. Package was released with patch release v1.0.5. Tested by running npm i node-tilify followed by node-tilify -h and it worked fine.

  7. Finally it was time to push all the tags to Github, ran git push --follow-tags command and then performed a release manually from GitHub to release v1.0.6 to the public.

User Testing

Manual user testing went quite well, which was unexpected. My tool only has 1 step to get it installed on another user's computer and they are ready to go to use the software. They did however point out a thing to fix on my documentation. The readme.md file mentioned the incorrect way to use the tool. It mentioned invoking the tool using node src/index.js -h which was now changed to node-tilify -h. Besides, they mentioned moving all the information regarding developer contributions like cloning a repo, installing the packages and running the repo code from the command line to contributing.md for better clarity. Also, they got stuck figuring out what passing a directory meant for input and output flags, so I explained it to them and they were able to get going after that point. Moreover, initially, they were reluctant to use toml configuration from the command line but then figured it out after reading the documentation a couple of times. Based on the feedback received the documentation was updated accordingly.

Learning Outcomes

This was a fantastic exercise for me considering I've never published packages to npm and releasing software to the public. I learnt how to test the software before publishing or releasing, publish a package on a registry, add git tags being part of the release, release the software on GitHub and perform user testing to gain valuable feedback from them to improve the documentation which in turn increases user adoption helping to capture wider audience who'd use the software.

Top comments (0)