簡體   English   中英

蓋茨比無法讀取 null 的屬性“childImageSharp”

[英]Gatsby Cannot read property 'childImageSharp' of null

我正在用 gatsby 構建我的第一個項目,但找不到解決圖像問題的方法。

我的代碼在這里

當我嘗試運行gatsby build此錯誤:

failed Building static HTML for pages - 10.907s

 ERROR #95313

Building static HTML failed for path "/posts/2"

See our docs page for more info on this error: https://gatsby.dev/debug-html


  27 |                         return (
  28 |                             <div className={blogListStyles.cards}>
> 29 |                                 <Img sizes={node.frontmatter.screenshot.childImageSharp.sizes} />
     |                                                                         ^
  30 |                                 <Link to={`/blog/${node.fields.slug}`}>
  31 |                                 <div className={blogListStyles.title}>{node.frontmatter.title}</div>
  32 |                                 <div className={blogListStyles.subtitle} dangerouslySetInnerHTML={{__html: node.excerpt}}></div>


  WebpackError: TypeError: Cannot read property 'childImageSharp' of null

  - blog-list-template.js:29
    src/templates/blog-list-template.js:29:73

  - blog-list-template.js:25
    src/templates/blog-list-template.js:25:28

我為此找到了很多解決方案,但沒有一個對我有用,我什至嘗試設置 Linux 子系統,因為我讀到這可能會解決問題,但它沒有

我多次檢查我的 .md 文件,但找不到任何錯字等

當我運行開發模式時,/posts/2 將是一個空白站點

如果有人能看看我的代碼,我將不勝感激,我在這里迷路了:(

提前致謝!

{node.frontmatter.screenshot && <Img... />}到我的代碼中,這確實讓我構建了它,然后發現我的 Markdown 文件中確實有錯別字,我沒有看到我之前檢查過的 100 次 - _-

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM