Reinitializing

Sometimes additional metadata can be available after we've created a module. A typical scenario can arise when we initialize our module as a Git repository and add a remote endpoint after creating the module.

Git and GitHub
If we've not used the Git tool and GitHub before, we can refer to        
http://help.github.com to get started. If we don't have a GitHub account, we can head to http://github.com to get a free account.

To demonstrate, we'll create a GitHub repository for our module. Let's head to GitHub and click on the plus symbol in the top-right, then select New repository:

We'll specify the name as hsl-to-hex and click on Create Repository.

Back in the Terminal, inside our module folder, we can now run this:

echo -e "node_modules\n*.log" > .gitignore
git init
git add .
git commit -m '1st'
git remote add origin http://github.com/<username>/hsl-to-hex
git push -u origin master

Now here comes the magic part; let's initialize again (simply press enter for every question):

npm init 

This time the Git remote we just added was detected and became the default answer for the git repository question. Accepting this default answer meant that the repository, bugs, and homepage fields were added to package.json.

A repository field in package.json is an important addition when it comes to publishing open source modules since it will be rendered as a link on the modules information page at http://npmjs.com.

A repository link enables potential users to peruse the code prior to installation. Modules that can't be viewed before use are far less likely to be considered viable.