How to create your own NPM package
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!
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?
(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
npm login is currently hanging on password. I'm trying to set up a package, but it just freezes.
@Nightstrike nvm, I fixed the version issue. ugh.
@Nightstrike agreed, its freezed
@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.
@Nightstrike Hi, I just found out that, its normal,
npm did it for security reason, so yeah copy and paste work
@IHZAQSTORM33 Nonetheless, I'm amazed they were able to do that. Console listeners are notoriously tricky.