Skip to content
← Back to Community
How to create your own NPM package
Profile icon
ironblockhd

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.
IMG_2794

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

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

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

IMG_2797

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

Voters
Profile icon
zelferry
Profile icon
Squirrel777
Profile icon
Highwayman
Profile icon
ironblockhd
Comments
hotnewtop
Profile icon
Nightstrike

npm login is currently hanging on password. I'm trying to set up a package, but it just freezes.

Profile icon
Nightstrike

@Nightstrike nvm, I fixed the version issue. ugh.

Profile icon
IHZAQSTORM33

@Nightstrike agreed, its freezed

Profile icon
Nightstrike

@IHZAQSTORM33 It's not a freezing issue. Somehow they found a way to disable CLI display but still listen for keyboard input. It works fine, it just throws me off, because I can't see the password input.

Profile icon
IHZAQSTORM33

@Nightstrike Hi, I just found out that, its normal,
npm did it for security reason, so yeah copy and paste work

Profile icon
Nightstrike

@IHZAQSTORM33 Nonetheless, I'm amazed they were able to do that. Console listeners are notoriously tricky.

Profile icon
Squirrel777

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?

Profile icon
zelferry

(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