当我使用npm安装fancyapps/fancybox#v2.6.1——save时,fancybox v2.6.1标记包将被安装。这个行为在文档中有描述

我想问一下,如何用纱线来做这个?

这个命令是正确的替代方案吗?在yarn文档中没有任何关于这种格式的内容。

yarn add fancyapps/fancybox#v2.6.1

当前回答

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

例如:

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

其他回答

在最新版本的Yarn中,它们要求在URL之前有包名。如果你正在安装一个发布到Github Packages的私有包,语法是这样的:

纱线添加@organization/packagename@https://github.com/organization/packagename,

它应该在package.json中产生这一行:

@organization / packagename”:“https://github.com/organization/packagename”

我在github存储库中使用这种简短的格式:

Yarn添加github_user/repository_name#commit_hash

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

例如:

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

对于ssh风格的url,只需在url之前添加ssh:

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

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

yarn add 'ssh://git@github.com:myproject.git#<branch,tag,commit>'
npm install 'ssh://git@github.com:myproject.git#<branch,tag,commit>'