Publishing your node package to npm registry is a pretty easy task. To publish to npm registry you should have valid user credentials. You either create your user at link https://www.npmjs.com/signup or you can create a user using following commands:
C:\Users\achana λ npm adduser Username: User12345 npm WARN Name must be lowercase Username: user_test Password: ******* Email: (this IS public) usertest@gmail.com Logged in as user_test on https://registry.npmjs.org/
If you already have a user then you can simply use npm login command to login to to npm registry. Once you are logged in, run the command npm whoami command to confirm that you are logged in.
Publishing a package
You can publish any folder which has a valid package.json file. To publish cd to the directory which has package.json file and then type npm publish command.
Note: Your package name must be a unique, so ensure that it is not in use by someone else. To confirm this go to:
https://www.npmjs.com/search?q=mypackage&page=1&ranking=popularity where mypackage is the name your package.
If while publishing you get following error then most likely the package already exists in the npm repository:
npm ERR! you do not have permission to publish "my-package".
Are you logged in as the correct user? : my-package
if the publish is successful then you should see following:

Publish successful!
Now switch over to the browser and browse to www.npmjs.com and search for your package to see if it is now visible in npm registry:

Your published package found in search
And voila !
Updating package
Since you’d also like to keep adding functionality to your packages and therefore would also like the update the package in the npm registry as well. For this you would need to do following:
- npm version <major|minor|patch>, this will ensure that your version in package.json is incremented.
- npm publish
When both the commands are successful then you can see your changes are updated in the npm registry.