DEV Community

Bregwin Jogi
Bregwin Jogi

Posted on

How to publish your node.js package to NPM

I recently added my node.js console application RefactorCode to NPM to make it easier for users to install the application without cloning the repo. It was surprisingly simple and I have laid out the steps below:

You need to first create an npmjs account from here: https://www.npmjs.com/

Image description

Once that's done, go to the root directory of the project, and type:

npm login
Enter fullscreen mode Exit fullscreen mode

This will take you to the login page and after being successfully authenticated, type npm publish to push the project to NPM:

Image description

And that's it!

Here is my package if you are curious:
https://www.npmjs.com/package/refactorcode


Other stuff

I made a release for the application by tagging a release:

git tag -a v1.0.1
Enter fullscreen mode Exit fullscreen mode

And the pushing it to github:

git push --follow-tags
Enter fullscreen mode Exit fullscreen mode

I also tested if others were able to access the application by asking my brother to try installing it, he was able to set it up from NPM pretty easily after looking at the README file.

Image description

Although, it is a bit harder compared to normal packages since you have to specify environment variables for the API key, but the screenshots helped.

Top comments (1)

Collapse
 
nozibul_islam_113b1d5334f profile image
Nozibul Islam

Great sharing this post..