Categories
Technology

How Create NPM Package With Scoped @organization

Introduction

Today we will learn how to create a NPM package like this https://www.npmjs.com/package/@vanpariyar/text-manipulation

I was wondering how I can make my own package in the javascript and publish it to the NPM registry ? πŸ€”.

So I found the below step that you can easily register your NPM package with your scoped. πŸͺ” ( This is Lamp in India πŸ’‘ πŸ˜„) Like if you see @angular/package-name

Requirements πŸ’―

  • Node.js installed
  • git installed
  • NPM account for publishing package.

Starting

Let’s start the development now.

mkdir text-manipulation
cd text-manipulation
Npm login

After npm login enter your username, password, email

npm init --scope=@my-org 
// OR
 npm init --scope=@my-username

Now you will have the prompt that you need to answer for your package. Like the Package version, Github Repo etc.

Now open index.js in your preferred editor. Then write your code in the file. πŸ–Š

Add .gitignore to ignore node_modules

# .gitignore

node_mudules

Then if you have a public account you need to add this parameter with the npm publish command.

npm publish --access public

Conclusion

Nice, πŸŽ‰ You have published your first NPM package.


If it is helpfulΒ and saves your valuable Time ⏱ please show your support πŸ‘‡.

Buy Me A Coffee

Buy me A Coffee, Thank you and canva ( For Beautiful designs ). Thanks for the reading πŸ‘.