How to create a module in npm?

4

The idea is to be able to download this module by npm install and be able to execute this package:

npm install nome-do-modulo --save

Once downloading could run on my project as follows:

nomeDoModulo = require('nome-do-modulo')
    
asked by anonymous 02.09.2016 / 18:32

1 answer

6

The steps to take are:

npm init

This 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 do not already have an account you can create it on the site and then use npm login on the command line, or directly npm adduser and then npm publish .

As I already have account for some time I do not remember the questions to ask but these steps should take you there.

    
02.09.2016 / 21:58