Featured image of post How Create NPM Package With Scoped @organization

How Create NPM Package With Scoped @organization

Create Npm Package With Scoped @organization with step by step instruction

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.

1
2
3
mkdir text-manipulation
cd text-manipulation
Npm login

After npm login enter your username, password, email

1
2
3
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

1
2
3
# .gitignore

node_mudules

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

1
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 👍.
Built with Hugo
Theme Stack designed by Jimmy