Publishing your First Typescript NPM Package

Sear Cheulong
2 min readJun 25, 2022

--

I assume that you already have at least the basic knowledge of NodeJs, NPM and Typescript.

Before, we start. Please make your devices has typescript and touch-cli install globally. If not, you can run command yarn global add typescript touch-cli.

  • typescript — to be able to use tsc command.
  • touch-cli — to be able to implement the touch command for Node.

First, create a new nodejs project

npm init -y

It will create package.json

Next, add dependencies

yarn add -D typescript
  • typescript — to code typescript in the project.

After that, you can run tsc init to generate tsconfig.json

touch index.ts

Now, let write some basic functions

Before go any further, we need to edit tsconfig.json and package.json

Finally, run yarn build

Now we will publish our package to npm

To create a profile for the public npm registry

npm config set registry https://registry.npmjs.org/npm login

After you logged in, you run npm publish

Go to npmjs.com and search rtl-checker

Congratulations, you published your first npm package.

Repository for this code https://github.com/cheulong/rtl-checker

Example for this package codesandbox

--

--

Sear Cheulong

Frontend Developer at Seven Peaks Software, looking to learn new thing and language enthusiast. ^^