[node.js] How to install package from github repo in Yarn

When I use npm install fancyapps/fancybox#v2.6.1 --save, so fancybox package at v2.6.1 tag will be installed. This behavior is described in docs

I want to ask, how to do this with yarn?

Is this command the right alternative? In yarn docs isn't anything about this format.

yarn add fancyapps/fancybox#v2.6.1

This question is related to node.js yarnpkg

The answer is


For GitHub (or similar) private repository:

yarn add 'ssh://[email protected]:myproject.git#<branch,tag,commit>'
npm install 'ssh://[email protected]:myproject.git#<branch,tag,commit>'

For ssh style urls just add ssh before the url:

yarn add ssh://<whatever>@<xxx>#<branch,tag,commit>

This is described here: https://yarnpkg.com/en/docs/cli/add#toc-adding-dependencies

For example:

yarn add https://github.com/novnc/noVNC.git#0613d18

I use this short format for github repositories:

yarn add github_user/repository_name#commit_hash