DEV Community

Cover image for Publish a package to directory πŸ“¦
Pierre-Henry Soria ✨
Pierre-Henry Soria ✨

Posted on • Updated on

Publish a package to directory πŸ“¦

Here are the easy simple steps to publish a new JS NPM package πŸ˜…

1. A GitHub account (optional; highly recommended) πŸͺ„

The first step, it to have a GitHub account (you probably have one already). This is where you will store your code (in a repository) and where your README file and the git repo links will be synced with your package page.

2. An account πŸ—

You will need to create an account on

3. Version your package πŸ“¦

Note: You can skip this section if you are releasing your very first version.

Make sure your code is ready to be published. Make sure you correctly mention the files you don't want to be included thanks to gitignore or .npmignore (following the .gitignore pattern rules).

Make sure your package.json file is properly formatted and contains all necessary information.


If so, you can commit everything with git and proceed to the release.

You can also add a repository section containing the GitHub link to your repo as show below:

  "repository": {
    "type": "git",
    "url": ""
Enter fullscreen mode Exit fullscreen mode

If so, let's create a stable version first thanks to npm version [ major | minor | patch ]

In my case, it will be npm version major, which will bump the version in your package.json to the major number (e.g., if your version was 1.0.0, it will now be 2.0.0).

The command will also create a new git tag.

4. Publish to NPM πŸš€

In the terminal, type npm login

Login as the user name you previously created. Confirm your password and mention your email address you used when creating your account.

Then, in the root directory of your project, enter
npm publish.


This will literally publish your package to the public NPMJS registry.

5. Let's check your package πŸ€—

Once that's done, go to{username}/packages


You should see your new package in there πŸ€— The name of your package with be the same as the name you mentioned in your package.json, "name" field.

You will also receive an email from npm confirming that your package has been published.


Congrats! πŸ₯³

Yaaay! πŸŽ‰ You are now all set! And your package is ready to be used by anyone πŸš€

Remove your package (or version) from NPM registry πŸ™ˆ

In case you wish to delete your package from the public registry, you can run a npm unpublish through the terminal with the name of your package.


πŸ‘‰ Would you like to speed up your understanding on building real applications and APIs in JavaScript? My course covering API and frontend development is now available on Udemy:

Top comments (2)

pierre profile image
Pierre-Henry Soria ✨

Let me know any feedback and thoughts πŸ€—

richardevcom profile image
richardev • Edited

I suggest devs to ALWAYS test their solution before publishing it. I recently wrote about it in similar manner but with different angle - here.

However, I think this is first time I'm seeing someone actually mentioning npm unpublish, haha.