How to Publish NPM Package to npmjs.com

2023/02/051 min read
bookmark this
Responsive image

Table of Contents

  1. Introduction
  2. Login to npmjs.com
  3. Publish the Package
  4. Conclusion

Introduction

This guide shows you how to publish an NPM package to npmjs.com in just a few steps.

Login to npmjs.com

Type npm init and follow the steps to log in to npmjs.com.

  npm init

Publish the Package

There are a few ways to publish an NPM package: private, public, or publish to an organization. Here, we're publishing as public, so type the command below at the root folder of your Node.js source code.

npm publish --access public

Conclusion

That's it. If there's no error, your package should be published to npmjs.com. Check the package under your account — you should be able to find it there.