npm install from GitHub repository


Did you know that you’re not limited to installing npm packages from the npm registry?

GitHub

You can also install packages from remote git providers like GitHub:

npm install https://github.com/<username>/<repository>

Here’s an example:

npm install https://github.com/remarkablemark/html-react-parser

npm will try install the package via git clone.

If you save the dependency, your package.json will look something like:

{
  "dependencies": {
    "html-react-parser": "git+https://github.com/remarkablemark/html-react-parser.git"
  }
}

Commit

The default commit is master, but if you want to install a specific commit, tag, or branch, you can do the following:

npm install <username>/<repository>#<commit>

For example:

npm install remarkablemark/html-react-parser#v0.10.5

Your package.json will look something like this if the dependency is saved:

{
  "dependencies": {
    "html-react-parser": "git+https://github.com/remarkablemark/html-react-parser.git#v0.10.5"
  }
}

Gist

You can even install a package from a gist:

npm install gist:<commit>

See example:

npm install gist:fd0837438d136e18c8e8eac559cd004a

Bitbucket

To install from another git provider like Bitbucket:

npm install <protocol>://[<user>[:<password>]@]<hostname>[:<port>][:][/]<path>[#<commit>]

The install would look something like this:

npm install git+ssh://[email protected]/<user>/<repository>.git

Addendum

Check out the npm-install documentation for more information.



If you enjoyed this post, please consider supporting this site!