To publish a package on npm, you first need to create an account on the npmjs.com website and also on the npm registry.
Creating an account on the npmjs.com website allows you to manage your user profile, publish packages to the npm registry (our current goal), and manage access to private packages.
The npm registry is where all publicly available npm packages are stored and distributed from.
In other words, to publish a (public) package on npm that will be available to anyone on the internet, you first need to register as a "publisher".
Use the npm adduser
command.
This command is used to create your auth token and npm RC.
> npm adduser
Username: your-username
Password: your-password
Email: (this IS public) [email protected]
Note: At the time of writing (April 2024), NPM seems to have implemented a more straightforward approach where they use your npm account data to create your registry account. The command will prompt a browser tab opening for you to authenticate. Once done, your account will be registered.
This command will ensure your account has been correctly registered.
# Display your current username
> npm whoami
# Update your email
> npm profile set email [email protected]
# Update your name
> npm profile set name "Your New Name" # update your name
- If you have any questions, don't hesitate to contact me following my social links or through my email at [email protected]
- If you find any typos or encounter any issues with this tutorial, please feel free to contact me or create an issue on GitHub so I could fix it.