How to Install a NPM Module from GitHub Branch

By  on  

In my journey to work more quickly with a project containing loads of dependencies, I've come across a few techniques I've not needed to use before. I previously wrote about How to Push to a Git Remote Branch of a Different Name -- this time we'll talk about installing a module from another repository instead of a published version.

To install a module from a GitHub branch instead of a tagged and published NPM module, simply reference the username, repository, and branch name:

"dependencies": {
    "eth-ledger-bridge-keyring": "darkwing/eth-ledger-bridge-keyring#work-in-progress",
}

This pattern is useful for a host of reasons, especially when trying to rapidly develop from local branches. Feel free to leave off the branch name if you just want to use master branch!

Recent Features

  • By
    Page Visibility API

    One event that's always been lacking within the document is a signal for when the user is looking at a given tab, or another tab. When does the user switch off our site to look at something else? When do they come back?

  • By
    7 Essential JavaScript Functions

    I remember the early days of JavaScript where you needed a simple function for just about everything because the browser vendors implemented features differently, and not just edge features, basic features, like addEventListener and attachEvent.  Times have changed but there are still a few functions each developer should...

Incredible Demos

  • By
    MooTools Typewriter Effect Plugin

    Last week, I read an article in which the author created a typewriter effect using the jQuery JavaScript framework. I was impressed with the idea and execution of the code so I decided to port the effect to MooTools. After about an hour of coding...

  • By
    Vertically Centering with Flexbox

    Vertically centering sibling child contents is a task we've long needed on the web but has always seemed way more difficult than it should be.  We initially used tables to accomplish the task, then moved on to CSS and JavaScript tricks because table layout was horribly...

Discussion

    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!