How to install package from github repo in Yarn

后端 未结 5 1838
遇见更好的自我
遇见更好的自我 2020-12-22 22:09

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

相关标签:
5条回答
  • 2020-12-22 22:36

    For ssh style urls just add ssh before the url:

    yarn add ssh://<whatever>@<xxx>#<branch,tag,commit>
    
    0 讨论(0)
  • 2020-12-22 22:38

    I use this short format for github repositories:

    yarn add github_user/repository_name#commit_hash

    0 讨论(0)
  • 2020-12-22 22:40

    You can add any Git repository (or tarball) as a dependency to yarn by specifying the remote URL (either HTTPS or SSH):

    yarn add <git remote url> installs a package from a remote git repository.
    yarn add <git remote url>#<branch/commit/tag> installs a package from a remote git repository at specific git branch, git commit or git tag.
    yarn add https://my-project.org/package.tgz installs a package from a remote gzipped tarball.
    

    Here are some examples:

    yarn add https://github.com/fancyapps/fancybox [remote url]
    yarn add ssh://github.com/fancyapps/fancybox#3.0  [branch]
    yarn add https://github.com/fancyapps/fancybox#5cda5b529ce3fb6c167a55d42ee5a316e921d95f [commit]
    

    (Note: Fancybox v2.6.1 isn't available in the Git version.)

    To support both npm and yarn, you can use the git+url syntax:

    git+https://github.com/owner/package.git#commithashortagorbranch
    git+ssh://github.com/owner/package.git#commithashortagorbranch
    
    0 讨论(0)
  • 2020-12-22 22:51

    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
    
    0 讨论(0)
  • 2020-12-22 22:57

    For GitHub (or similar) private repository:

    yarn add 'ssh://git@github.com:myproject.git#<branch,tag,commit>'
    npm install 'ssh://git@github.com:myproject.git#<branch,tag,commit>'
    
    0 讨论(0)
提交回复
热议问题