Your first Typescript Package on NPM (Part 2/2)

Arbaz Ajaz
2 min readNov 4, 2020

--

Publishing on npmjs.org

We’ll divide it into two steps

  1. Creating an account at npmjs.org.
  2. Logging in using command line and publishing your package.

If you’re facing any issues, we’ll be discussing them at the end of the article but read the article first, you might find the answer you’re looking for in it too.

Step 1: Creating an account at npmjs.org

If you have not registered yourself at npmjs.org, now is the right time for it. Go to https://www.npmjs.com/signup and sign up for an account.

After you’re done, login at https://www.npmjs.com/ and they’ll send a verification email on the email address you provided while signing up.

If you created an account prior to reading this or just created an account, please confirm if you have verified your email address by checking your mailbox (emails) and looking for a verification link sent by npm Inc <notifications@npmjs.com> and visiting the link provided in the email.

If you do not verify your email address, you won’t be able to publish your package(s).

Once you have verified your email address, we’re good to go.

Step 2: Logging in using command line and publishing your package

Let’s go into the root folder of the package you need to publish to npmjs.org.

Open the command line and login to your npmjs account using the following command:

npm login

After you’ve successfully logged in, enter the following command to publish your package on npmjs

npm publish

After it is done publishing, you can view your package by going to the following link:

https://npmjs.org/package/<package-title>

(Replace <package-title> with the package name you’ve chosen for your project).

How to install your newly published package:

It’s a unique name, same as you install other packages

npm install <package-name>

(Replace the <package-name> with your package name.)

Issues you might face and fixes:

If the package name is taken by the time you are ready to publish your package:

Look for a different unique package name and replace the “name”: “<new-name>” inside package.json file.

If you’re unable to publish your package and getting a 403 Error, you did not verify your email address, go to npmjs.org and click on resend verification email (it’s a big banner right at the top of the page after you login). Check your mails for the verification email and click the link provided inside the email.

--

--

Arbaz Ajaz
Arbaz Ajaz

Written by Arbaz Ajaz

Arbaz is a MERN Stack developer, aiming to make learning programming accessible and straight forward

No responses yet