How do I publish my repository to npm?

How do developers submit their GitHub repositories to the npm?

Write your answer…

3 answers

First, create an account on 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

Reply to this…

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

  • 💬 Ask programming questions without being judged

  • 🧠 Stay in the loop and grow your knowledge

  • 🍕 More than 500K developers share programming wisdom here

  • ❤️ Support the growing dev community!

Create my profile

Quick reminder: Hashnode != Google.

Here's your answer

Reply to this…