【问题标题】:Netlify and yarn not finding Github packageNetlify 和 yarn 找不到 Github 包
【发布时间】:2021-07-02 13:50:35
【问题描述】:

我正在使用 yarn 构建一个站点并将其托管在 Netlify 上。我想将另一个 repo 集成为一个包,但我不想将该包放在 npm 注册表中,因为它的使用非常有限。我托管了package publicly via GitHub here 并将其添加到我的package.json

  "dependencies": {
    "@ourjapanlife/findadoc-localization": "^1.0.0",
    .
    .
    .
   }

我可以在本地构建站点,并且一切运行良好。但是,当我部署到 Netlify 时,我收到以下错误:

10:38:06 PM: [1/4] Resolving packages...
10:38:06 PM: error Couldn't find package "@ourjapanlife/findadoc-localization" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
10:38:06 PM: Error during Yarn install

我创建了一个.yarnrc 文件,如下所示并将其添加到我的项目的根目录中:

@ourjapanlife:registry" "https://npm.pkg.github.com"

我对此进行了很多研究,但大多数建议都与 private GitHub repos 有关。我对这个包是公开的很好,但我不希望它集中托管,因为它只是一些对更广泛的社区几乎没有用的 i18n 文件。 This answer also looked promising,但从 .npmrc 切换到 .yarnrc 并没有解决我的问题。

【问题讨论】:

    标签: yarnpkg netlify github-package-registry


    【解决方案1】:

    一位合作者通过运行帮助我解决了这个问题:

    yarn add https://github.com/ourjapanlife/findadoc-localization 
    

    package.json 中的结果条目如下所示:

      "dependencies": {
        "@ourjapanlife/findadoc-localization": "https://github.com/ourjapanlife/findadoc-localization",
        .
        .
        .
       }
    
    

    此时我可以删除.npmrc / .yarnrc 并删除prenetlify 步骤。

    它在 Netlify 上成功构建并通过 yarn.lock 解析为最新包。

    事实证明,我在 npm 和 github 注册表之间切换并手动编辑了 package.json。最好通过命令行重新安装。

    【讨论】:

      猜你喜欢
      • 2020-02-07
      • 2018-09-26
      • 2020-11-06
      • 1970-01-01
      • 2019-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多