I’m a pretty big fan of the npm registry. For many developers, especially those coming from bootcamp backgrounds, being introduced to Node and NPM is a pivotal moment.

Let’s take a look at how we can go about adding a _scoped package _to NPM using Node.js and TypeScript.

The Plan

The idea here is to be able to install and use our own npm package under the scope of your npm username. e.g npm install @user/package

We can just as easily configure an existing project. However if this is new to you, it may prove more beneficial to test this concept in a clean directory for the sake of getting familiar.

Setting up a new project

First, we can create a new directory and initialize Node with TypeScript as a dependency. The name we give to this folder will also be the name we publish our package to. See the official docs for best practices on naming conventions.

mkdir once && cd once
npm init -y && npm i typescript 
npm i @types/node -D

#typescript #nodejs #npm

Publish a Scoped Package to NPM using TypeScript
1.45 GEEK