How do developers submit their GitHub repositories to the npm?

Write your answer…

3 answers

First, create an account on npmjs.com. With npm installed, login in the CLI:

npm login

If you don't have a package.json file, create one with:

npm init

If your library is meant to be used in the browser, replace "main" by "browser" in the package.json.

Because your repo can contain a lot of things, make sure to include a "files" field in the package.json to publish just those files to npm. When you are sure all looks fine, publish it with:

npm publish

These days, all package names are used. You can create packages scoped to your username. Give your package a name like @yourusername/packagename and publish it with:

npm publish --access public
Spot On1
1 Beer1

Hashnode is building a friendly and inclusive dev community. Come jump on the bandwagon!

  • 💬 A beginner friendly place

  • 🧠 Stay in the loop and grow your knowledge

  • 🍕 >500K developers share programming wisdom here

  • ❤️ Support the growing dev community!

Register ( 500k+ developers strong 👊)