Here's an marvelous ๐งต thread on โงฉ
Beginners ๐ Guide To โจ Publishing JavaScript Projects ๐ On @npmjs
#100DaysOfCode #JavaScript #TypeScript #CodeNewbie
Continue reading ๐
แ Deciding Package Name
Finding the right name for your project plays a key role in making it discoverable
It should be ๐
๐น Available on GitHub & NPM
๐ธ Short and rememberable
๐น Relevant to the purpose
For the purpose of this thread, I am using a random word "integrated"
แ Creating package.json
Create a new directory and run "npm init -y" in it. This will create a basic package.json file.
Open this file in your favorite code editor and fill in the license, description, and author fields.
๐
แ During Development
While you're working on making your project come to life, keep the version to 0.x.x.
This will ๐
๐น Indicate that it's in development
๐ธ Lets you push breaking changes
แ Writing Code
You can make a cli app or, a library that runs in the browser or Node.js.
For example, I'll make an app.js and module.export a simple console.log.
Whatever you export from this app.js (or so-called entryfile) will be accessible to users of your library.
๐
แ Setting Project Type
We need to tell npm where is code for our project.
To do that ๐
๐น Open package.json
๐ธ For lib, add a key "main" and set it to the path of entryfile
๐น For cli, add a key "bin" and set it to the path of executable
๐ธ Adding both is also supported
๐
แ Login To npmjs
It's time that we publish our project to @npmjs ๐
Run "npm login" and put in your username, password, and public email address.
This will link npm cli with your npmjs account.
If you don't have an account, creating one is pretty easy!
๐
แ First Publish
Let's do it! ๐ค Run the command "npm publish".
This will publish your JavaScript project to npm.
Now anyone can use your project by running ๐
npm install <project_name>
You'll also get a lovely ๐ email from npm that it's published.
๐
แ Adding Keywords
Once your project is ๐ฅณ published. Time to spread the word about your project!
Re-open package.json & fill the keywords from similar packages. That will get let your project come on searches ๐
Keywords show during searches & on your package page on npm
๐
Special โจ thanks to @AyushCodes for giving me the idea ๐ก
Thank you so much! ๐ for reading. If you can follow me, and retweet ๐ this thread to your developer gang, it would be impressive ๐คฉ
๐
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.