【问题标题】:gatsby-source-prismic-graphql production build throws an error when querying for a sharp processed imagegatsby-source-prismic-graphql 生产版本在查询清晰的处理图像时抛出错误
【发布时间】:2020-07-25 08:29:16
【问题描述】:
childImageSharp {
  fixed(width: 320, height: 320, cropFocus: ENTROPY) {
    ...GatsbyImageSharpFixed
  }
  fluid(maxWidth: 800, quality: 90) {
    ...GatsbyImageSharpFluid
    presentationWidth
  }
}




1:23:36 AM: error There was an error in your GraphQL query:
1:23:36 AM: Unexpected error value: "failed to process https://images.prismic.io/{MYURL}/9164c1cd-2aed-4955-bbf5-23ea20861ac4_565.jpg?auto=compress,format\nError: ENOENT: no such file or directory, open '/opt/build/repo/.cache/caches/gatsby-source-prismic-graphql/tmp-ced6c46e221e339dcd73ea911900fbca.jpg'"

似乎插件首先需要从 prismic 下载图像,但查询在下载图像之前运行,并且在运行生产构建时抛出上述错误。知道如何解决这个问题吗?

【问题讨论】:

  • 我有同样的错误。但它第一次出现是在一周前左右,而不是之前。奇怪

标签: gatsby prismic.io


【解决方案1】:

我相信您可以通过将以下代码添加到您的 gatsby-node.js 顶部来解决此问题:

var fs = require("fs")
var dir = "./.cache/caches/gatsby-source-prismic-graphql"

exports.onPreBootstrap = () => {
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir)
  }
}

来源——https://github.com/birkir/gatsby-source-prismic-graphql/issues/162#issuecomment-600641723

【讨论】:

    【解决方案2】:

    我想我通过降级来修复它 "gatsby-source-prismic-graphql": "3.3.1"

    这随后引发了gatsby-browser.js 错误,但生成了图像

    然后升级到

    "gatsby-source-prismic-graphql": "3.4.1-alpha.0"

    这清除了之前的gatsby-browser.js 错误,所以现在它运行良好

    【讨论】:

      猜你喜欢
      • 2020-02-05
      • 1970-01-01
      • 2019-09-20
      • 1970-01-01
      • 2019-09-29
      • 1970-01-01
      • 2020-06-03
      • 1970-01-01
      • 2019-04-02
      相关资源
      最近更新 更多