Learn to Code via Tutorials on Repl.it!

← Back to all posts
How to create your own NPM package
ironblockhd (427)

This post will teach you how you can make your own NPM packages in 4 simple steps that later can be required by anyone.

Let's get started!

First if you haven't, you need to create a npm account on their website. You will need to verify your accounts email before you can upload anything.

Now, copy the module you want to upload into an empty bash repl and navigate into it using the cd-command. It's important that you press the "run"-button before doing so.

Then simply enter npm init to create a package.json file.
.

We're almost done! Now you can login with the npm login command

If you're logged in you can then call the npm publish command to publish your package.

Yay, now you can use my id generator! Hope you enjoyed this tutorial!

Comments
hotnewtop
Squirrel777 (141)

It works just fine, but when I try to update and run it in another repl I get this error:
Please verify that the package.json has a valid "main" entry
Do you know how to fix this?

zelferry (0)

(I'm from Brazil) I was trying to post my package but I couldn't because I was giving 404 error, let's see if it will work now :3