gpt4 book ai didi

node.js - 如何在 Yarn 中从 github repo 安装包

转载 作者:IT老高 更新时间:2023-10-28 21:47:32 26 4
gpt4 key购买 nike

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

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

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

yarn add fancyapps/fancybox#v2.6.1

最佳答案

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

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 语法:

git+https://github.com/owner/package.git#commithashortagorbranch
git+ssh://github.com/owner/package.git#commithashortagorbranch

关于node.js - 如何在 Yarn 中从 github repo 安装包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43411864/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com