【问题标题】:Use Yarn within a docker that is hosting a git submodule在托管 git 子模块的 docker 中使用 Yarn
【发布时间】:2019-04-11 16:07:26
【问题描述】:

我有一个开发环境 git repo,其中包含我应用程序的所有各种组件作为子模块,每个子模块都有自己的 docker 容器,将文件夹作为卷安装。

一些子模块也需要彼此,所以为了减少混淆,我只是将它们列在我的 package.json 中

{
 "dependencies": {
    //...
    "myapp-common": "https://path-to-my-repo.git",
   }
}

这很好用,除了,当我需要在我的 docker 中运行 yarn 时。当我使用node-sass 之类的工具时,会根据运行yarn 的操作系统安装不同的软件包。

我遇到的问题是当我运行yarn install 等时,我得到了这个错误:

root@ea69cb8f4e7f:/app# yarn
yarn install v1.10.1
[1/4] Resolving packages...
[2/4] Fetching packages...
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads https://path-to-my-repo.git
Directory: /app
Output:
fatal: Not a git repository: ../.git/modules/myapp
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

任何想法如何解决这个问题?

【问题讨论】:

    标签: git docker yarnpkg


    【解决方案1】:

    不是最理想的,但我通过创建一个临时移动 .git 文件的 bash 脚本解决了这个问题

    #!/bin/bash
    mv /app/.git /app/.git.bak
    yarn
    mv /app/.git.bak /app/.git
    yarn start
    

    【讨论】:

      猜你喜欢
      • 2019-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-07
      • 2016-11-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多