How to create a module in npm?

Asked

Viewed 706 times

4

The idea is to get this module down npm install and be able to run this package:

npm install nome-do-modulo --save

Once downloading could be run in my shape design below:

nomeDoModulo = require('nome-do-modulo')

1 answer

6

The steps to take are:

npm init

that will create a package.json and will ask you a number of things about the module you are creating.

Then I usually tag the code (give it a version), after committing with:

git tag 1.0.0

and to send to npm:

npm publish

If you don’t have an account yet you can create on the site and then use npm login on the command line, or else do directly npm adduser and then do the npm publish.

As I’ve had an account for some time I don’t remember the questions to ask but these steps should take you there.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.