如何从 Yarn 中的 github repo 安装包 [英] How to install package from github repo in Yarn

查看:48
本文介绍了如何从 Yarn 中的 github repo 安装包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 npm install Fantasyapps/fancybox#v2.6.1 --save 时,将安装 v2.6.1 标记的fancybox 包.此行为在 docs

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

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

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

这个命令是正确的选择吗?在 yarn docs 中与此格式无关.

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

yarn add fancyapps/fancybox#v2.6.1

推荐答案

您可以通过指定远程 URL(HTTPS 或 SSH)将任何 Git 存储库(或 tarball)作为依赖项添加到 yarn:

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.

以下是一些示例:

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]

(注意:Fancybox v2.6.1 在 Git 版本中不可用.)

要同时支持 npm 和 yarn,可以使用 git+url 语法:

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

这篇关于如何从 Yarn 中的 github repo 安装包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆