盖茨比错误:TypeError [ERR_INVALID_ARG_TYPE]

问题描述

我正在关注安德鲁·米德(Andrew Mead)关于盖茨比(Gatsby)训练营的YouTube教程,该教程最多3:10:00 一切工作正常,但是一旦我安装了gatsby-remark-relative-imagesgatsby-remark-images插件并将它们添加gatsby-config.js文件中以显示图像,当我运行npm run develop时就会收到类似的错误消息如下所示。

enter image description here

下面是我的gatsby-config.js文件

/**
 * Configure your Gatsby site with this file.
 *
 * See: https://www.gatsbyjs.org/docs/gatsby-config/
 */

module.exports = {
  /* Your site config here */

  siteMetadata:{
    title:'Gatsby Bootcamp',author:'Author'
  },plugins: [
    'gatsby-plugin-sass',{
      resolve:'gatsby-source-filesystem',options:{
        name: 'src',path: `${__dirname}/src/`
      }
    },'gatsby-plugin-sharp',{
      reslove: 'gatsby-transformer-remark',options:{
        plugins:[
          'gatsby-remark-relative-images',{
            resolve:'gatsby-remark-images',options:{
              maxWidth:750,linkImagesToOriginal: false
            }
          }
        ]
      }
    }
  ]
}

请帮助!预先谢谢你。

解决方法

作为documentation explains,您必须在gatsby-node.js中添加以下代码段:

const { fmImagesToRelative } = require('gatsby-remark-relative-images');

exports.onCreateNode = ({ node }) => {
  fmImagesToRelative(node);
};

这将获取您的gatsby-source插件返回的每个节点,如果找到匹配的文件,则将markdown前置数据中的任何绝对路径转换为相对路径。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...