当我使用npm安装fancyapps/fancybox#v2.6.1——save时,fancybox v2.6.1标记包将被安装。这个行为在文档中有描述
我想问一下,如何用纱线来做这个?
这个命令是正确的替代方案吗?在yarn文档中没有任何关于这种格式的内容。
yarn add fancyapps/fancybox#v2.6.1
当我使用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
其他回答
对于GitHub(或类似)私有存储库:
yarn add 'ssh://git@github.com:myproject.git#<branch,tag,commit>'
npm install 'ssh://git@github.com:myproject.git#<branch,tag,commit>'
我在github存储库中使用这种简短的格式:
Yarn添加github_user/repository_name#commit_hash
对于ssh风格的url,只需在url之前添加ssh:
yarn add ssh://<whatever>@<xxx>#<branch,tag,commit>
纱2 +
在Yarn 2中,从远程url安装略有变化。具体来说,远程url必须以包名作为前缀。所以对于github这意味着:
yarn add '<package name>@https://github.com/<github user>/<github repo>'
确保<package name>匹配repo的包的"name"字段中的值。json文件。
通过URL片段添加head=<branch>或commit=<full commit hash>
yarn add '<package name>@https://github.com/<github user>/<github repo>#head=<branch name>'
如果你想从github上的Yarn monorepo中安装一个单独的包,你可以在URL片段中添加workspace=<包名>:
yarn add '<package name>@https://github.com/<github user>/<github repo>#head=<branch name>&workspace=<package name>'
在最新版本的Yarn中,它们要求在URL之前有包名。如果你正在安装一个发布到Github Packages的私有包,语法是这样的:
纱线添加@organization/packagename@https://github.com/organization/packagename,
它应该在package.json中产生这一行:
@organization / packagename”:“https://github.com/organization/packagename”