Premium lesson

Publishing Packages on the npm Registry

npm·2 min read·Jan 1, 2025

As an npm user, you can create and publish packages on the npm registry, either to use them in your own projects or to share them with other developers.

In this lesson, we'll create and publish a new package named hello-world.

Setting up your npm account

Before being able to publish packages to the npm registry, you will first need to:

  1. Create an npm account on the official npm website at npmjs.com/signup.

  2. Sign in to your account through the command-line interface interact with the npm registry using the npm login command:

    $ npm loginnpm notice Log in on https://registry.npmjs.org/Login at:https://www.npmjs.com/login?next=/login/cli/a51sf3xf-526a-459a-910b-bcd41436706dPress ENTER to open in the browser...
  3. Verify which npm account you're currently signed in with using the npm whoami command:

icon light bulb key

Unlock the Build CLI Apps in JavaScript & Node.js module

Learn how to build, integrate, and safeguard scalable CLI tools, scripts, and apps with JavaScript, Node.js, npm, and Git.

You get immediate access to:

  • 45 focused lessons across JavaScript, Node.js, npm, and Git
  • 17 real-world projects with commented solutions
  • Ongoing updates to this bundle
  • Lifetime access to this bundle
Unlock this module