如何在纱线中从github repo安装包

问题描述 投票:81回答:4

当我使用npm install fancyapps/fancybox#v2.6.1 --save时,将安装v2.6.1标签的fancybox包。 docs中描述了此行为

我想问一下,如何用yarn做到这一点?

这个命令是正确的选择吗?在yarn docs并不是关于这种格式的。

yarn add fancyapps/fancybox#v2.6.1

node.js yarnpkg
4个回答
142
投票
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.

2.6.1在fancybox git版本中不可用

yarn add https://github.com/fancyapps/fancybox [remote url]

yarn add https://github.com/fancyapps/fancybox#3.0  [branch]

yarn add https://github.com/fancyapps/fancybox#5cda5b529ce3fb6c167a55d42ee5a316e921d95f [commit]

15
投票

对于ssh样式的url,只需在url之前添加ssh:

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

9
投票

这里描述:https://yarnpkg.com/en/docs/cli/add#toc-adding-dependencies

例如:

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

4
投票

对于GitHub(或类似)私有存储库:

yarn add 'ssh://[email protected]:myproject.git#<branch,tag,commit>'
npm install 'ssh://[email protected]:myproject.git#<branch,tag,commit>'
© www.soinside.com 2019 - 2024. All rights reserved.