Releasing my npm package with a Tag
Tags: opensource, npm, devops, git
Published: 2021-11-27 02:35:58

I released a npm package in public for my Static Site Generator(SSG)! I was very surprised and impressed that I could do that like other packages that I used before:white_flower:

## Package managers
[npm](https://docs.npmjs.com/packages-and-modules/contributing-packages-to-the-registry) is the package manager for the Node JavaScript platform. My SSG uses JavaScript, so I decided to use it to release my package.

## How did I create a package?
First of all, I opened Windows PowerShell and went to my SSG folder. Second, I typed `npm login`. It allowed me to enter Username, Password, Email. After I verified my email address, I could get this page:
![npm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xyx861cdcxe54nupy0c3.png)

## Tag my Release
[Tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging#_annotated_tags) can be used as specific points in history in open source projects to help users in the repository easily navigate to important parts of the code history.
I added `v0.9.0.` as a practice, and then created a `v1.0.0` release with `git tag -a v1.0.0 -m "my version 1.0.0"` and checked all tags I added with the `git tag` command. My original release number was `v0.1.0`, so I changed package.json, yarg, README files to modify my version. After I added those files, commit, and push, I also pushed tags to main with the `git push --follow-tags` command.

## Published my public package to the npm registry
Based on the [npm document](https://docs.npmjs.com/creating-and-publishing-unscoped-public-packages), the way to publish a package is using `npm publish` command. When I run it, I had the error below:
```
PS C:\Users\Mizuho\Desktop\OSD600\pajama-ssg> npm publish
npm notice
npm notice package: node-ssg@1.0.0
npm notice === Tarball Contents ===
npm notice 701B   __mocks__/fs.js
 ...
npm notice 842B   yargsConfig.js
npm notice === Tarball Details ===
npm notice name:          node-ssg
npm notice version:       1.0.0
 ...
npm notice total files:   25
npm notice
npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/node-ssg - Package name too similar to existing package nodessg; try renaming your package to '@mizuho/node-ssg' and publishing with 'npm publish --access=public' instead
```
I firstly thought someone used the same name of the package, but it was just the name I didn't change inside the package.json file when I did `npm init`.
I changed `name` from `node-ssg` to `pajama-ssg`, and successfully released!

## User Testing
My partner Gustavo tried to install and run my program, but it failed. The error message said it was caused by `prettier`. Since I moved prettier inside the `devDependencies` instead of `dependencies` in my package.json file. I corrected the location and pushed to git, and I [updated the npm version number](https://docs.npmjs.com/updating-your-published-package-version-number) with the `npm version 1.0.1` command. Then I published it again.
He could run my program and I also could run his program.
![run Gustavo's project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dr7cvi1pk015z8wz7q0i.png)
However, I couldn't see any files in my directory where I installed Gustavo's package, the `node_module` folder was installed globally(under my C drive). Another friend, Kevan helped me and suggested to do `npm install` inside the directory. It created a package.json and I did `npm i <packagename>` again, then I finally had the files inside the directory:tada:

## Modified README and CONTRIBUTING file
I modified those files and their contents to match by installing the npm package. The installation and usage became simpler. When I modified the README file, I didn't pay attention enough and realized that I had to change the CONTRIBUTING file as well. Because of my small changes, my release number grew to `v1.0.4`. I learned that I needed to think more about the affected area:sweat_smile:

## Conclusion
I didn't expect that I could release a npm package in public. Through this course, I'm having good opportunities to communicate with other programmers(students, people online, professors) and experiences to publish in public such as this blog, a npm package, my open source project, and PRs. I'm a shy person so all of these social aspects are new to me, but I feel I'm getting more comfortable with all of it(I hope!):star2:

## Links
My npm package: [pajama-ssg](https://www.npmjs.com/package/pajama-ssg)
All you need is `npm i pajama-ssg`, and run `npx pajama-ssg -i <file name>`.
File name is your text or markdown files that you would like to convert to html. Please store a file(s) inside the project folder.

[My GitHub repo](https://www.npmjs.com/package/pajama-ssg) | [Gustavo's npm package](https://www.npmjs.com/package/gmot-ssg) | [Kevan's npm package](https://www.npmjs.com/package/text-ssg)
My friends' SSGs are great! Check them out:eyes::sparkles: