【问题标题】:how to install specific branch of git repository using yarn?如何使用纱线安装 git 存储库的特定分支?
【发布时间】:2018-04-24 02:44:31
【问题描述】:

我可以使用 yarn 安装一个 GitHub 包,但不能安装其他包。请让我知道这可能是什么问题。

我可以加https://github.com/fancyapps/fancybox#3.0 但不是https://github.com/opentripplanner/otp-react-redux#result-post-processor

ravis-MacBook-Pro:gitprojects ******$ mkdir test
ravis-MacBook-Pro:gitprojects ******$ cd test
ravis-MacBook-Pro:test ***********$ yarn init
yarn init v1.6.0
question name (test): 
question version (1.0.0): 
question description: 
question entry point (index.js): 
question repository url: 
question author: 
question license (MIT): 
question private: 
success Saved package.json
✨  Done in 11.54s.

ravis-MacBook-Pro:test ******$ yarn add https://github.com/fancyapps/fancybox#3.0
yarn add v1.6.0
info No lockfile found.
[1/4] ????  Resolving packages...
[2/4] ????  Fetching packages...
[3/4] ????  Linking dependencies...
warning " > @fancyapps/fancybox@3.0.48" has unmet peer dependency "jquery@>=1.9.0".
[4/4] ????  Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ @fancyapps/fancybox@3.0.48
info All dependencies
└─ @fancyapps/fancybox@3.0.48
✨  Done in 1.35s.


ravis-MacBook-Pro:test *******$ yarn add https://github.com/opentripplanner/otp-react-redux#result-post-processor
yarn add v1.6.0
[1/4] ????  Resolving packages...
error Can't add "otp-react-redux": invalid package version undefined.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
ravis-MacBook-Pro:test *******$ 

【问题讨论】:

  • 我在这里进退两难.. 两个答案都是正确的。如果不用修改源,我得用yarn 1.3.2安装。我将使用 botika 的版本,因为这意味着我使用的是开发人员用来安装 repo 的正确版本

标签: node.js yarnpkg


【解决方案1】:

你需要使用你的 git remote url 并在 hash(#) 之后指定分支。

yarn add https://github.com/opentripplanner/otp-react-redux.git#result-post-processor

在特定 git 分支、git commit 或 git 标记处从远程 git 存储库安装包。

yarn add <git remote url>#<branch/commit/tag>

【讨论】:

  • 我想要特定分支结果后处理器的代码
  • 请在回答中使用上述命令。 git remote url 并在 hash(#) 后指定分支
  • 如果对你有帮助,请告诉我。
  • 如果此答案或任何答案解决了您的问题,请考虑通过单击复选标记并投票来接受它。这向更广泛的社区表明您已经找到了解决方案,并为回答者和您自己提供了一些声誉。没有义务这样做。
  • 我正在使用确切的命令,但它失败了。我原来的问题也是一样的。您可以在我的原始帖子中看到错误。你能从你的机器上显示命令吗
【解决方案2】:

更新

请注意,对于 Yarn 2+,您需要在 URL 前加上包名:

yarn add otp-react-redux@https://github.com/opentripplanner/otp-react-redux#head=result-post-processor

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-26
    • 1970-01-01
    • 2018-08-02
    • 1970-01-01
    • 2013-01-07
    • 2013-01-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多