DEV Community

Tuan Thanh Tan
Tuan Thanh Tan

Posted on

Publishing my package to NPM

Introduction

Hello everyone, my name is Dustin. Today, I'd like to talk about my experience of publishing my static site generator to NPM. It's quite a fun experience as I finally made my project up and running in public.

Process

I've used this as instruction to publish it to NPM.

You can check it out here

Because I already built my project for quite a long time so, I can skip most of the steps, and just focus on this step and some steps that help me understand the semantic versioning and dist-tags.

When I first start using command line npm publish to publish the project, I had to sign up and log in to NPM. But I encountered an error where it said something like this

npm ERR! code E403
npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/cv-ssg - Forbidden
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.
Enter fullscreen mode Exit fullscreen mode

As it stated right there, the error code is 403 which means it involved sign up or log in part. After a few minutes, I just realized that I forgot to verify email. So just make sure that if this is your first time publishing a project to npm, you have your email verified.

While working with updating version stuff, I also had to delete e2e snapshot file and run it again because when I changed the version in the package.json, and pushed the repo to github, the github action won't be happy. I'm not sure if I'm doing the right way that other people do. If I don't, please show me. Thank you.

I tried to test it as a client's perspective by installing Nodejs and then I do npm install -g cv-ssg to install it globally so that I can run it anywhere I like. As expected, it worked very well, I got no error. Or maybe I'm just testing the bright side of the project.

In order to tackle that problem, I got one of my friend who is also a student of this course to test it out on his computer. Fortunately, he also ran it successfully a few times using cv-ssg command.

Wrap up

For this lab, it didn't require us to code anything as this is like a final step for the project, not quite the final one because if the project is delivered to end users and they found bugs or errors. It needs to be fixed and published again. The cycle keeps going and going.

Top comments (0)