我正在用gatsby构建我的第一个项目,但是找不到解决图像问题的方法。
我的代码在here
当我尝试运行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将是一个空白站点
如果有人可以看一下我的代码,我将不胜感激,在这里我迷路了:(
谢谢!
答案 0 :(得分:0)
在我的代码中添加了{node.frontmatter.screenshot && <Img... />}
,这让我得以构建它,然后发现我在markdown文件中确实有错别字,在-_-