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.
|
|
After npm login
enter your username, password, email
|
|
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
|
|
Then if you have a public account you need to add this parameter with the npm publish
command.
|
|
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, Thank you and canva ( For Beautiful designs ). Thanks for the reading 👍.