从模板中删除图像会导致使用Gatsby找不到文件?

时间:2019-11-27 03:45:04

标签: reactjs gatsby gatsby-image

当我下载Gatsby并从文件中删除模板图像时,我收到错误消息,并且服务器无法工作。当我将图像放回原位时,它又可以工作了。我真的不知道这是怎么回事。

为什么没有放置模板的模板就无法使用模板,删除模板后似乎完全破坏了。

这些是我收到的错误消息:

ERROR #11321  PLUGIN
> icon (src/images/gatsby-icon.png) does not exist as defined in gatsby-config.js. 
> Make sure the file exists relative to the root of the site.
ERROR 

> There was an error compiling the html.js component for the development server.
> See our docs page on debugging HTML builds for help https://gatsby.dev/debug-html
> ENOENT: no such file or directory, open 'src/images/gatsby-icon.png'


  38 | 
  39 |     if (cacheBusting !== "none") {
> 40 |       iconDigest = (0, _gatsbyCoreUtils.createContentDigest)(_fs["default"].readFileSync(pluginOptions.icon));
     |                                                                             ^
  41 |     }
  42 | '''

1 个答案:

答案 0 :(得分:1)

该错误强烈暗示您没有删除对图像的所有引用。

  按照gatsby-config.js中的定义,

icon(src / images / gatsby-icon.png)不存在。

gatsby-config.js仍然是参考。您还应该使用IDE文本搜索并浏览所有文件(如果它们包含任何引用)。